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

Question on Row Selection and Deselection

3 Answers 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
towpse
Top achievements
Rank 2
towpse asked on 05 Aug 2009, 03:13 PM
Greets.

When I deselect a row, I'm wondering if there is anyway I can tell that another row will be selected immediately afterwards; that is that the row is being deselected because another row has just been selected.

If I have one row selected and a user unchecks (deselects) it, I want the UI to reset itself to its default view where no rows are selected.
If I have one row selected and a user selects another row, deselecting the previous one in the process, I don't want to reset the UI rather I just want to populate the UI based on the new selected row.

This will get rid of a slight flicker that occurs when selecting a new row when a previous selection already exists.

I doubt there is any way since deselection has to occur before selection; and at that point the row count will always be 1.
Just wondering if anyone can make some helpful suggestions.

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 10 Aug 2009, 07:51 AM
Hi towps,

In order to achieve this scenario, attach an event handler to the OnRowSelecting client event of the grid and add the following javascript to your page:

        var selectedIndex=-1;  
        function RowSelecting(sender, args)  
        {              
            if (selectedIndex == args.get_itemIndexHierarchical())  
            {  
              args.set_cancel(true);  
              selectedIndex = -1;  
            }  
            else 
            {  
              selectedIndex = args.get_itemIndexHierarchical();  
            }  
        } 

I hope this helps.

Best wishes,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
towpse
Top achievements
Rank 2
answered on 10 Aug 2009, 04:09 PM
I'm not sure if that particular example helps in the situation i described. It looks like that will jsut not runt he row selecting event if the user is selecting the row that is arleady selected is that it?
0
Tsvetoslav
Telerik team
answered on 11 Aug 2009, 11:38 AM
Hello towps,

The row-selecting event will indeed be canceled but before that the row-deselecting event will occur which will effectively deselect the row. So the purpose of the solution below is to allow you to deselect the row by clicking on it once it has been selected.

Besides, please note that for your scenario to work you need to have AllowMutliRowSelection set to false.

All the best,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
towpse
Top achievements
Rank 2
Answers by
Tsvetoslav
Telerik team
towpse
Top achievements
Rank 2
Share this question
or