Hi all,
I have a table, in this table, I can select a row, and then I do one action, the table is loaded again, and the row that I had selected, It must appear selected again.
It work correctly, but my problem is the number of page, for exemple...If the row selected is in the page one, when I reload the table, the row is selected, but the number page is other, I make a function that select the row, and the page, but the problem is that when the table is reloading the order of records is different to when the table is loaded.
This is my function:
$('#table tbody tr').each( function(i) {
var aData=$('td', this);
var iIdRow=$(aData[1]).text();
if (i%10==0){
nMod=i;
}
if (iId==iIdRow){ //iId is the identificator of the row
$('#table tbody tr:eq('+i+')').addClass('row_selected'); //select the row
nPageIni=nMod; //store the ini page
}
} );
Then:
oTable =$('#table ').dataTable( {
"bRetrieve": true,
"bDestroy": true,
"iDisplayStart": nPageIni,
"fnDrawCallback":
function() {
clickRowHandler();
},
"aoColumnDefs": [
{"bVisible": false,
"aTargets": [ 9 ]
}],
"aaSorting": [ [9,'asc']],
"aoColumns": [
null,
null,
null,
null,
null,
null,
null,
{"sType": "date-euro"},
null,
null]
} );
Please, somebody could you help me?
Thanks in advance.
I have a table, in this table, I can select a row, and then I do one action, the table is loaded again, and the row that I had selected, It must appear selected again.
It work correctly, but my problem is the number of page, for exemple...If the row selected is in the page one, when I reload the table, the row is selected, but the number page is other, I make a function that select the row, and the page, but the problem is that when the table is reloading the order of records is different to when the table is loaded.
This is my function:
$('#table tbody tr').each( function(i) {
var aData=$('td', this);
var iIdRow=$(aData[1]).text();
if (i%10==0){
nMod=i;
}
if (iId==iIdRow){ //iId is the identificator of the row
$('#table tbody tr:eq('+i+')').addClass('row_selected'); //select the row
nPageIni=nMod; //store the ini page
}
} );
Then:
oTable =$('#table ').dataTable( {
"bRetrieve": true,
"bDestroy": true,
"iDisplayStart": nPageIni,
"fnDrawCallback":
function() {
clickRowHandler();
},
"aoColumnDefs": [
{"bVisible": false,
"aTargets": [ 9 ]
}],
"aaSorting": [ [9,'asc']],
"aoColumns": [
null,
null,
null,
null,
null,
null,
null,
{"sType": "date-euro"},
null,
null]
} );
Please, somebody could you help me?
Thanks in advance.