What is the Purpose of columns[i][search][value] ?
What is the Purpose of columns[i][search][value] ?
Dear team,
I am using the jquery datatable for one of my project. I am integrating the column based search in server side. But, i don't know what is the purpose of using the column [inxex][search][value]. Because, whenever i am using the below code all column[index][search][value] passes the same value in ajax.
oTables.columns().eq( 0 ).each( function ( colIdx ) {
$( 'input', oTables.column( colIdx ).footer() ).on( 'keyup change', function () {
oTables
.column( colIdx )
.search( this.value )
.draw();
} );
How can i get the independent column search values ?
For Ex :
Search Input Box1 - Column 0
Search Input Box2 - Column 1
Pass Value :
column[0][search][value] - Search Input Box1 Value
column[1][search][value] - Search Input Box2 Value
Kindly, let us know your valuable suggestion.
Replies
Can you link me to the page showing the error so I can debug it please. The parameter you mention should contain the search value for the column.
Allan
Hello Allan,
Thanks for your response. I will create the test environment in live and provide the open url to show case the issue.
Hello Allan,
Here with i have created the live testing environment. Kindly, check it out.
I have placed the each column search box in the table header. When the user type some characters in the particular column it passes same value to all column search value.
Kindly, check the post data.
columns[0][search][value] - Same value ,
columns[1][search][value] - Same value ,
columns[2][search][value] - Same value
Live Url :
http://testtable.agilecentre.com/testing
Hello Allan,
Awaiting for your valuable response.
Hi,
Thanks for the link. Your table appears to have two
thead
elements, which is not valid HTML. If you need two rows in the header, put them both in a single header.Also you are using
oTables.column( colIdx ).footer()
is doesn't really make much sense when the inputs are in the header. That is returning null, which means that jQuery is using all of the inputs on the page for every iteration of the loop. You need to use theheader()
method to get the header cells.Allan
Hi allen,
Thanks for your response. As discussed i have changed the header() function. But, facing another issue.
When i disable the
"bSortCellsTop": true,
the keyup event is working perfectly.When i enable the
"bSortCellsTop": ,
then keyup event is not working. I have updated the testing repo. Please, let us know your suggestion.Thanks,
prem
I don't think that will find any input elements will it? Use:
Allan
Hi allen,
No luck of using the mentioned code. Updated the code in test environment. Pls, check it out.
http://testtable.agilecentre.com/testing
Hi alen,
Finally found the solution with the help of css.
// CSS
// Html
// Script
Thanks alen for your valuable response. It is nice and extraordinary plugin.
Fantastic to hear you got it sorted out :-)
Allan
Hello Allan,
When we disable the
"searching": false
it affects the independent column search value. It passes the empty data.So, i am forcing to enable the search box. Is that way to disable the search which does not affect the independent search column value.
To handle the situation i am using the below css.
.dataTables_filter, .dataTables_info { display: none; }
Thanks,
prem
If you disable searching, then, you've disabled searching :-).
I've you want to just remove the DataTables filtering input element, use the
dom
option to remove it.Allan
Hello Allan,
Thanks , I forgot to use the dom option. I will try it out.
Is that possible the get the
columns[1][name]
value during the column search. Because, it would be really helpful we can get the name for server side processing.Currently i am getting the value as empty.
columns[1][name] = empty value
Thanks,
Prem
To set a name use the
columns.name
option.Allan