Load selected item's page

Load selected item's page

mpkhourympkhoury Posts: 5Questions: 2Answers: 0

Hi,

I am trying to load DataTable displaying the selected row (item was selected and recorded on previous steps) but I haven't been successfull so far. I constructed a function that set the selection based on a value (row_val) that is searched in a specific column (by_column_index). The problem is the page loaded is always the first, and not the nth where the selected item lives.

Here's the function:

function selectRow(dt, row_val, by_column_index) {

if (dt) {

var index = dt.rows().eq( 0 ).filter( function (rowIdx) { 
  return dt.cell( rowIdx, by_column_index ).data() === row_val ? true : false; } );

if (index) {
  var page_index = dt.row( index ).select();
  dt.page( dt.page() ).draw( false );
}
else {
  dt.rows().deselect();
  dt.page( 0 ).draw( true );
}

}

}

I thought .page() could give the the selected item's page, but that is not the case. That seemed to be quite simple at first, but I already spend 3+ hours reading manuals, posts, etc.

Any thoughts?

Cheers,

Marcelo

This discussion has been closed.