3.2.0

scroll to grid position

I have used the sample code for scrolling a selected row into view when a grid is first displayed. This works well when you scoll to a row select it, do some processing, then come back to the grid. The selected row is scrolled into view on the grid when you return. I have a situation where I select a row in the grid and do some processing. The processing results in the selected row being removed from the grid. When I return to the grid page the grid does not scroll to the position where the selected row used to be. Is there a way to get this behavior so I can scroll back to the same area in a long list even if the actual selected row has been removed?
JH
March 20,
I assume to scroll the position you are using setCurrentRow(position).
That requires a row number and if you have removed a certain row then it should go to the next row.
ShepherdOwner
March 20,
Here is the code I am using

function scrollIntoViewRowRemoved(scrollIndex) {
var row = this.getTemplate("row", scrollIndex);
var data = this.getTemplate("layout").getContent("data");
var left = this.getTemplate("layout").getContent("left");
var scrollbars = this.getTemplate("layout").getContent("scrollbars");
debugger;

try {
var top, padding = parseInt(data.element ().currentStyle.paddingTop);

if (data.element().offsetHeight + data.element().scrollTop <
row.element().offsetTop + row.element().offsetHeight ) {
top = row.element().offsetTop + row.element().offsetHeight - data.element().offsetHeight;
left.element().scrollTop = top;
data.element().scrollTop = top;
scrollbars.element().scrollTop = top;
}
}
catch(error){
// ignore errors
}
}

This code actually works even when the row is removed from the table but it quits working once the grid is sorted on a column. We persist our column sort so our users can have their preferred sort once they set it.


JH
March 20,
This forum post has a good solution to my problem. Basically all that is happening is that you are capturing the position of the scrollbar(s) and then setting the scrollbar postion(s) to the captured postion when the grid is redisplayed.

/javascript.forum.1668.5/can-i-specify-the-starting.html
JH
May 10,

This topic is archived.

See also:


Back to support forum