PDA

View Full Version : GridPanel - scroll to bottom default



Zdeno
28 Apr 2010, 9:36 AM
Hello is there any chance how to scroll gridpanel to bottom row without reloading gridpanel and setting focus on last row? Ofc you need reload panel everytime when you want to see actual records. But is there any way to scroll to bottom without "jumping" from top row?

TIA

cnelissen
28 Apr 2010, 9:55 AM
If you could get the element of the last item in the grid, then scrollIntoView would probably work... Something like:

last_item_element.scrollIntoView(grid);

Zdeno
28 Apr 2010, 11:08 AM
This method looks same like

myGrid.getSelectionModel().selectRow(records.length-1);
Is there any method how i can fix gridview, reload data ( not sure how without reloading GridPanel element ), and move focus and selectedRow to last row. E.g. you got focus on last row and you add two records to database. Then you reload the grid and move focus to last row. So from user's view you will see only change from before the last but one to last one. Is this method possible or not?

cnelissen
28 Apr 2010, 12:45 PM
You could always insert the record into the store at the same time it is being added to the database, in which case you wouldn't need to reload the store. Or you could use a data writer on the store, then let the store perform the update to the database, again bypassing the need for a store reload.

You can add an item to the store like so:



var rec = myGrid.getStore.recordType({
field1: 'value1',
field2: 'value2'
});
myGrid.getStore().add(rec);

jcagumbay
29 Apr 2010, 7:14 AM
If you could get the element of the last item in the grid, then scrollIntoView would probably work... Something like:

last_item_element.scrollIntoView(grid);

thanks a lot! it solved my problem.. :D