Ardit Meti Ardit Meti - 5 days ago 5
Javascript Question

How to select the corresponding page of row datatable

I want to preselect a row in my datatable and I am using the

row('#rowID').select()
function for that. It does select the row but it doesn't select the corresponding page where that row is.
I know there exists an option displayStart:

$('#example').dataTable( {
"displayStart": 20
} );


to start on a specific page, but it requires the number of the row in the source list not the id of that row.
Is there a way how to initialize the page using the rowID?

EDIT: The data is taken from the server, not in client.

Answer

Use row().show() API method to display page containing required row.

Please note that you need to include additional JS file //cdn.datatables.net/plug-ins/1.10.12/api/row().show().js for this API method to work.

table.row(1).show().draw(false);    

See this example for code and demonstration.

Comments