If the user tabs into a ListGrid or TreeGrid and performs a selection with cursor keys, that focus position is remembered internally. So when the user tabs out and in again, the cursor focus remains at the previous position. So far so good.
However if the data of the Grid has changed this behavior is confusing. Assume a search dialog with a hitlist as ListGrid. If the search criteria have changed and the search was performed again the hitlist gets populated with totally different data. There is no reason why the focus should still be at position say 7 when I tab into the hitlist. Note: If the new data has less rows (e.g. < 7) then the focus position is reset to 0.
Hence, I am looking for a way (API method) to (re)set the focus but cannot find any.
I found ListGrid.getFocusRow() but in my tests it always returned null and there is also no setFocusRow where I could pass 0.
Does anybody have a hint for me how to solve this problem without dumping the ListGrid and creating a new one whenever the data has changed?
You want to reproduce what I am talking about?
0. Unplug your mouse :)
1. Go here:
http://www.smartclient.com/smartgwt/...nce_empty_grid
2. Tab into the list (Tab order is somewhat confusing here) and select something other than the first row using arrow down key.
3. Tab out to the buttons and perform "Clear Data" and then "Set Data".
4. Tab back into the ListGrid (and assume the data would now be something totally different).
You will see that the position from step 2. is still focused.
However if the data of the Grid has changed this behavior is confusing. Assume a search dialog with a hitlist as ListGrid. If the search criteria have changed and the search was performed again the hitlist gets populated with totally different data. There is no reason why the focus should still be at position say 7 when I tab into the hitlist. Note: If the new data has less rows (e.g. < 7) then the focus position is reset to 0.
Hence, I am looking for a way (API method) to (re)set the focus but cannot find any.
I found ListGrid.getFocusRow() but in my tests it always returned null and there is also no setFocusRow where I could pass 0.
Does anybody have a hint for me how to solve this problem without dumping the ListGrid and creating a new one whenever the data has changed?
You want to reproduce what I am talking about?
0. Unplug your mouse :)
1. Go here:
http://www.smartclient.com/smartgwt/...nce_empty_grid
2. Tab into the list (Tab order is somewhat confusing here) and select something other than the first row using arrow down key.
3. Tab out to the buttons and perform "Clear Data" and then "Set Data".
4. Tab back into the ListGrid (and assume the data would now be something totally different).
You will see that the position from step 2. is still focused.
Comment