Making the selected row visible
Making the selected row visible
I'm trying to do what should be a simple thing but haven't been able to find a way to make it work. After the user adds a new record to a table, I want to select that record and then make the record visible. The selection is no problem but I can't find a way to make the row visible. I'm not using pagination or the scroller extension. This is the code to do the selection. Is there a way to make the row visible after selecting it?
function SelectFormula (formulacode) {
dtFormulas.ajax.reload(function() {
dtFormulas.row( function ( idx, data, node ) { return data[0] === formulacode ? true : false; } ).select();
});
}
This question has an accepted answers - jump to answer
Answers
Look into using
page.jumpToData()
plug-in.For example, include JS file for the
page.jumpToData()
plug-in and call the following method after the table data has been reloaded.See more articles about jQuery DataTables on gyrocode.com and contact us if you need help with your project.
If you aren't using paging, do you mean you just want to scroll the document to that row?
If so use
row().node()
to get thetr
element in question and then scroll to it (either using a jQuery plug-in or your own position calculation, perhaps with jQuery's$().position()
method).Allan
Allan,
Yes, I just want to scroll to that row. Can you give me some specific code for that? I'm far from an expert on this stuff! Thanks.
should do it. You'd need to fill in the jQuery selector for your row of course.
Allan
p.s. I should have said use
$().offset()
, not$().position()
above. The code in this post is correct.