Go to Row function
Go to Row function
Hi! Datatables is terrific! I'm still in the midst of evaluating on whether it can do everything I need it to, but so far it's looking good! Thanks for such a great product!
I'm somewhat stumped on something almost expected to be there: being able to "go" to a specified row even if it's on another "page"(i.e., specify a row and display the page it's on if not the current page).
I have a datatable whose first column is hidden, it gives the value of a unique record ID. I am writing a function that you can give the record ID to, and it will apply a "selected_record" class to that row (using a loop). This is no problem, but if paging is enabled, and the "target record" is on a different page than the one currently displayed, I'd like to programmatically go to that page so that it's visible.
The function "fnPageChange('string')" is there, but I have to figure out what the current page being displayed is, and what page the "target row" is on.
To do this, I used the "fnInfoCallback" on Initialization to set some global variables with the "iStart","iEnd", and "iTotal" values. "Rows per Page" I can get from oSettings, but not "iStart, End, Total" (should I be able to?).
So I need to know:
-- Num Total Rows
-- Max Rows Per Page
-- Number of Pages
-- Current Start Row Displayed
-- Current End Row Displayed
and in the loop searching for the specified record:
-- current page being displayed
-- page the target record is on
so that in addition to setting the "selected_record" class, I can go to that page if it isn't visible.
I was able to do this after some wrangling, but I have to call the "fnPageChange" callback for the number of times equal to the difference of "current page" and "target page". Do you know of a simpler way to do this?
Is enhancing the "fnPageChange" function to accept either a row number or a page number possible? (A row number seems preferable). This would be a tremendous convenience I'm sure many would appreciate! Or- maybe add a function named "fnGoToRow(rowNum, callback())" - the callback would be what you want to happen once this row is displayed - in my case it would be just highlighting that row and then calling a function to display the record described by that row.
I might have missed something totally obvious, and there might be a simple solution, but if not, I believe adding this feature would be doable and many might appreciate it. Thanks for any help or suggestions.
I'm somewhat stumped on something almost expected to be there: being able to "go" to a specified row even if it's on another "page"(i.e., specify a row and display the page it's on if not the current page).
I have a datatable whose first column is hidden, it gives the value of a unique record ID. I am writing a function that you can give the record ID to, and it will apply a "selected_record" class to that row (using a loop). This is no problem, but if paging is enabled, and the "target record" is on a different page than the one currently displayed, I'd like to programmatically go to that page so that it's visible.
The function "fnPageChange('string')" is there, but I have to figure out what the current page being displayed is, and what page the "target row" is on.
To do this, I used the "fnInfoCallback" on Initialization to set some global variables with the "iStart","iEnd", and "iTotal" values. "Rows per Page" I can get from oSettings, but not "iStart, End, Total" (should I be able to?).
So I need to know:
-- Num Total Rows
-- Max Rows Per Page
-- Number of Pages
-- Current Start Row Displayed
-- Current End Row Displayed
and in the loop searching for the specified record:
-- current page being displayed
-- page the target record is on
so that in addition to setting the "selected_record" class, I can go to that page if it isn't visible.
I was able to do this after some wrangling, but I have to call the "fnPageChange" callback for the number of times equal to the difference of "current page" and "target page". Do you know of a simpler way to do this?
Is enhancing the "fnPageChange" function to accept either a row number or a page number possible? (A row number seems preferable). This would be a tremendous convenience I'm sure many would appreciate! Or- maybe add a function named "fnGoToRow(rowNum, callback())" - the callback would be what you want to happen once this row is displayed - in my case it would be just highlighting that row and then calling a function to display the record described by that row.
I might have missed something totally obvious, and there might be a simple solution, but if not, I believe adding this feature would be doable and many might appreciate it. Thanks for any help or suggestions.
This discussion has been closed.
Replies