I am using a JQuery DataTable.
In my server side code, I am re-trieving the record id and passing it to my javascript function.
My javascript function will look for the row as per the row id and then set the class to selected.
function selectBuyer(agid)
{
$('#tr_buyer_' + agid).addClass("row_selected");
}
This works and highlights the row accordingly.
However I would like the datatable to navigate to that record. So if it was on the 3rd page, it will display the 3rd page. Currently right now, if I navigate to the third page, it will show the highlighted row.
Any ideas?
http://datatables.net/plug-ins/api
I found a similar question and it directed me to the datatables api. There is a function called fnDisplayRow. It will display the appropriate page with the row you send it.
I just need to do some tweaking to mold it into my particular scenario
I've used DataTables before and very often somewhere online there is a solution for most problems. I've been checking out the documentation and I have found this option iDisplayStart.
So maybe you could get the index of row_selected and use the iDisplayStart to start on that record.
var count = $('table tr.row_selected').index();
$('table').dataTable({
"iDisplayStart": count
});
If you actually wanted to start on the table, then you could round the start to the nearest 10 or 5.. etc..
count = Math.round(count / 10) * 10;
EDIT
In order to use round and for this to work, you would need to use floor really.
count = Math.floor(count / 10) * 10;