DataTables search child row content and child row field name ?
DataTables search child row content and child row field name ?
matt.crawfoord
Posts: 31Questions: 13Answers: 0
hi all,
The DataTables search bar does not let me search for content within child rows content and child rows field name .
because the child row field name is dynamic ,so how can i search for content with child rows content and child rows field name ??
I tried the solution, by adding the javascript function ..but it still doesn't work,
<script>
......
table.columns().every( function () {
var that = this;
var header = this.header();
$( 'input', this.footer() ).on( 'keyup change', function () {
that.column( header.getAttribute('data-search-index')*1 ) // *1 to make it a number
.search( this.value ).draw();
} );
} );
</script>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th ></th>
<th data-search-index="3">datetime</th>
<th data-search-index="3">message</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th>datetime</th>
<th>message</th>
</tr>
</tfoot>
</table>
Can someone please help me out?
Thanks
This discussion has been closed.
Answers
You would have to add the content of the child rows into a column of the table that the DataTable can search. As you say the child row content is dynamic so there is no way DataTables and search it.
Allan
hi allan,
from my code , i have add
but still can't search child row , What are any potential errors that I am overlooking?
Without a test case it is impossible to say, but I don't really see form the above code how that addresses the point I made above. Does that include the data that should be searchable in a hidden column?
Allan
hi allan,
how to include the data in a hidden column?
It depends on how you are generating your table. Assuming it is in the data source object for the row you would just include it like any other data.
Again, it is virtually impossible to say without a test case showing me how you are using DataTables.
Allan
hi allan,
my json output is looks like as below, each key and value is different ,datetime and message is parent row the others is child row ,I am new to datatable, can you give me an example about it ?
Sure - the priority support options are available here.
If you give a link to a test case I could take a look at it.
Allan