This is a migrated thread and some comments may be shown as answers.

[Solved] Setting an initially selected row

0 Answers 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
tmlipinski
Top achievements
Rank 1
tmlipinski asked on 01 Jun 2009, 02:02 PM
Hi,

I have a simple grid:
- no paging
- client side row selection allowed (single selection)
I have the id of the last selected row (let's say (for simplicity) - it's index in the grid) stored somewhere (let it be Session). When I load the page with this grid I want to select this row automatically.
I do the following (all client side):
- hook to GridCreated event
- supply the event handler like this:
function GridCreatedHandler(sender, eventArgs) {  
  var master = sender.get_masterTableView();  
  master.get_dataItems()[<stored row index>].set_selected(true);  
OK, it seems to work well. The desired row gets automatically selected. When I click on any other row - the previous gets deselected, the new one - selected.
But when I click on an already selected row (the last selected one, not neccessarily this <stored row index> one) this row gets deselected and the subsequent clicks don't want to select it.
If I comment out this "set_selected" statement selecting and deselecting works as expected.
It is independent from the used browser.

What should I do to achieve my goal?

Regards
Tomasz

No answers yet. Maybe you can help?

Tags
Grid
Asked by
tmlipinski
Top achievements
Rank 1
Share this question
or