I'm adding a batch of rows to a WebDataGrid in javascript using
for (i = 0; i < n; i++) myGrid.get_rows().add(myDataArray[i]);
adding works perfectly, but the grid also scrolls to bottom after this operation.
I'd like to scroll it to top, and I've seen the set_topScroll(0) method, but it doesn't work. Actually, I found out that even after adding rows, get_topScroll() always returns 0, so my set_topScroll() has no effect.
Any idea to solve this problem?
Hi elvandar,
By default, adding row should not scroll the grid to bottom. Could you please attach a small isolated sample, demonstrating this behavior, in order to be able to provide more insight. Thank you.
Hello elvander,
If you still need assistance with the matter, please let me know.
Yep, it works. Thanks :)
Hi elvander,
This is happening because you re adding the rows client-side, and the grid is scrolled to bottom to show the last added record. So a possible workaround is to scroll to the first row after executing the LoadData function. for example:
var grid;
function LoadData(sender, e)
{
var WebDataGrid1 = $find('<%: WebDataGrid1.ClientID %>');
grid = WebDataGrid1;
var numeroRighe = WebDataGrid1.get_rows().get_length();
for (i = numeroRighe; i > 0; i--)
WebDataGrid1.get_behaviors().get_editingCore().undoBatchUpdate(WebDataGrid1.get_rows().get_row(0));
}
for (i = 0; i < 10; i++)
var arrData = [i + "-1", i + "-2", i + "-3", i + "-4"];
WebDataGrid1.get_rows().add(arrData);
setTimeout("grid.get_rows().get_row(0).get_element().scrollIntoView();", 100);
return true;
Hope this helps.
Any news or hint?
Hi Nikolay. Thanks for your support. Sorry for the delay but I've been occupied with some urgent issues.
Attached to this post there's a small sample reproducing the problem. Clicking on the button "Load" fills the grid with ten records, and you can see the grid scrolls to bottom. This happens on Chrome, Firefox and Internet Explorer.
Net Advantage 2012.1, no SR, Visual Studio 2010, Net Framework 4.0.