When the app runs I see the cloned header but is disappears when the ajax data is returned.
That's because you do:
$('#dtDataChanged').empty();
then:
$('#dtDataChanged thead tr').clone().appendTo ...
Without seeing the full code I can't tell if you are using columns.title to set the column title text, but from your description I guess not. You are emptying the table and then trying to move parts around. Try doing the clone first.
Answers
Not in DataTables, but you can use a simple bit of jQuery to do it before you initialise the DataTable:
You could clone the original row if you just want a copy.
Thanks Allan,
what is the exact code to copy the header and where do I add this.
Is this the correct place.
To copy the header you would use
$().clone()
:and yes you would add it before the DataTable initialisation.
Cheers
Got it working.
Sorry wrong post
Hi Kevin,
I now have the second header working.
I've just noticed the search fields are not working.
What do I need to get these working again.
http://www.surplusanywhere.com/surplusAnywhere7
http://live.datatables.net/rumakepe/1/edit
Probably will need to change the event listener. Here is an example I have with a working complex header search input:
http://live.datatables.net/hepeqiro/1/edit
Kevin
I updated my other example:
http://live.datatables.net/rumakepe/2/edit
Note I added
class="column_search"
to the search inputs and changed the event handler to this:Kevin
Thanks Kevin,
cooking with gas now......
Cheers
Steve Warby
HI guys,
I have this working okay in my existing app.
In that app I make an ajax call and process the data.
I then build the datatable.
I am building another app and using the same logic.
When the app runs I see the cloned header but is disappears when the ajax data is returned.
The only difference is I make the ajax call while creating the datatables.
I have tried to add
in various places but can't get it to work.
I can't show a link because of sensitive data.
What is the correct placement of the piece of code.
1. The append header
2. Build the search boxes & 'keyup' code.
Cheers
Steve Warby
That's because you do:
then:
Without seeing the full code I can't tell if you are using
columns.title
to set the column title text, but from your description I guess not. You are emptying the table and then trying to move parts around. Try doing the clone first.Allan