Adding a link on the nested data table

I would like to add a download link, just before search box. I am using third level nested data table. This data creates dynamically on AJAX respond data.
I am using the following plugins;
Datatable
nested data table

 Second and third level of table is shown, when user click on the table rows. How I can add download link for the last level of the datatable ?

 var appendDownloadLink = $(".dataTables_filter");
    		                    
appendDownloadLink.prepend('<a class="download">Download</a>');

Open in new window


JSfiddle
Yakup KAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
You need to add this to your drawCallback option in your settings
var settings = {
  "iDisplayLength": 20,
  "bLengthChange": false,
  "bFilter": true,
  "bSort": true,
  "bInfo": false,
  "drawCallback" : function() {
		var appendDownloadLink = $("table table td .dataTables_filter label");
 		appendDownloadLink.each(function(i, e) {
    	$(e).before('<a class="download">Download</a>');
    })
  }
};

Open in new window


What is happening? In your first attempt you were trying to bind to the table before it had been rendered. In the above setup the drawCallback function is called when the table has completed rendering. Now you can do your manipulation.
To get to the search in the 3rd level we need to discount the searches in the first two levels - hence the "table table" selector - after that we find the .dataTables_filter class and the label immediately after that.
Finally we add the link before the label.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Yakup KAuthor Commented:
Thanks a lot Julian. You are the best!
Julian HansenCommented:
You are welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DOM

From novice to tech pro — start learning today.