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

Single click item not highlighted as selected

3 Answers 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tracy Dryden
Top achievements
Rank 1
Tracy Dryden asked on 16 Sep 2011, 09:06 PM
I have a radGrid and a radWindow on a page. Row selection on click IS turned on for the grid. The radAjaxManager is set up so that both the radGrid and the radWindow are trigger controls, and both update themselves and the other control.

When a row is double-clicked in the grid, I open the radWindow and display the records details. If you double-click another row while the radWindow is open, the detail display changes to the new record. I also have Next and Previous buttons on the window that change the selected record in the grid (using MasterTableView.selectItem(nrow)) and update the radWindow display. That all works perfectly.

I have also set it up so that while the radWindow is open the user can single-click a row in the grid to update the radWindow display. I use the OnSelected event for this purpose (hooking the OnRowClick event interferes with the OnRowDblClick event handler). The detail display in the radWindow gets updated with the new row correctly, but the row selected by the single-click is not highlighted to indicate that it has been selected! Worse, when I click the next or previous button on the radWindow, the selected record in the grid is moved relative to the highlighted row, which was the last row double-clicked or selected by next/prev buttons, rather than relative to the row I single-clicked. It's acting as if when a row is single-clicked it is only temporarily selected. When the radWindow is closed, single-clicking seems to work perfectly.

Is this a known issue with a known work-around? How do I get the single-click to select the row, highlight it as selected, and keep it selected?


3 Answers, 1 is accepted

Sort by
0
Tracy Dryden
Top achievements
Rank 1
answered on 19 Sep 2011, 04:21 AM
To update:

When the row is single-clicked it DOES temporarily get highighted as selected, but after the radWindow is updated the highlight reverts back to the previously selected row. On my slower laptop this is very obvious.

Even though the OnSelected and OnDeselected events are not cancellable I tried returning true to see if that made any difference. It doesn't.

I'm not using any postback events from the grid for any of this behavior. I handle all single-click, double-click and selecting/deselecting events client-side, and I use the radTabStrip (within the radWindow) client-side click method to cause the postback to the server.

It appears there is something more that I need to do after handling the radTabStrip click event that updates the radWindow that will cause the single-click selected row to remain selected, but I don't have to do anything to get the proper behavior on double-click.
0
Tracy Dryden
Top achievements
Rank 1
answered on 19 Sep 2011, 09:10 PM
I've solved the problem. Posting the solution here for anyone else who has the same problem.

The cause of the problem is that, apparently, the OnRowSelected event handler MUST EXIT before the selected row is properly selected and highlighted! (Why this is so when the event is called OnRowSelected, which would imply that the row has already BEEN selected, is up to Telerik to answer. The is also an OnRowSelecting event, which I would expect to operate in this manner.)

My SelectNext, SelectPrev and OnRowDblClick functions were all causing OnRowSelected to be executed, but it exited BEFORE they initiated the callback to update the radWindow, therefore they were working correctly. When single-clicking on a row the OnRowSelected function initiated a callback to update the radWindow, which apparently prevented completion of the event, so the row was never properly selected and highlighted. To solve this I used a setTimeout to initiate the callback, and then let the OnRowSelected function exit normally. It works perfectly.
0
Tracy Dryden
Top achievements
Rank 1
answered on 19 Sep 2011, 10:16 PM
NOTE: I discovered an additional problem in trying to solve this one: My SelectNext, SelectPrev and OnRowDblClick all initiate a callback to update the radWindow. But those three functions also cause the OnRowSelected event handling function to be called, and that function also tries to initiate a callback to update the radWindow! That callback is usually aborted by the second one, so no harm is done, but it's pretty sloppy. Also, the OnRowSelected event fires before the OnDblClick event handler gets called! Depending on the length of the setTimeout, the OnDblClick event handler may not get called at all! It works in the case of SelectNext and SelectPrev because those functions are called based on button clicks outside of the radGrid, but it stills tries to initiate the callback twice. To solve this problem I decided to just let OnRowSelected do most of the work:

SelectNext and SelectPrev do not attempt to initiate a callback. They simply select a row and let the OnRowSelected event initate the callback for the new row.

OnDblClick does not attempt to initiate a callback unless the radWindow is not already visible. If the window was visible then OnRowSelected will have already initiated the callback for the double-clicked row (and this event handler might not have even been called). If the window is not visible, then OnDblClick initiates the callback (and the window is shown).
Tags
Grid
Asked by
Tracy Dryden
Top achievements
Rank 1
Answers by
Tracy Dryden
Top achievements
Rank 1
Share this question
or