selected rows and filter
selected rows and filter
I wrote an application that contain a form with a dataTable table. This table has multi selected rows capabilities.
What i want to do, is to submit with the form the selected rows.
Also, a row can be selected only if the date in the 7th column is greater or equal at first of actual month.
To do that, i add a hidden input in the form.
This is my code that select a ligne with the date test and at the end, the loop for add the row's ID inside the hidden input.
$('#a_table tbody').on( 'click', 'tr', function () {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
var today= yyyy+'-'+mm+'-'+01;
var m=$('td',this).eq(6).text();
if(m>=today||m=='0000-00-00'){
$(this).toggleClass('row_selected');
}
var a='';
$('.row_selected').each(function(){
a+=$('td',this).eq(0).text()+'/';
});
$('#a_table_select').val(a);
} );
So now my issue:
When i use the filter box to find a particular row, the class that was added when we select a row ('row_selected') was removed. So i can't see if a row was already select (the CSS that highlight the row was removed).
So how a row stay select when i use the filter.
thanks
thierrydkk
Answers
Hi,
I found the mistake.
the data inside the table were generated by serverside methode. And, each time, that i have inserted a lettre in the search box, the server send back the answer, and refresh the table.The row i've selected was recreated without the class "row_select".
For me, i've thinked that the serverside request was executed just for get the data and not for filtered the datas