Question on Row Selection and Deselection

4 posts, 0 answers
  1. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 05 Aug 2009 Link to this post

    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.
  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 10 Aug 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 10 Aug 2009 Link to this post

    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?
  5. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 11 Aug 2009 Link to this post

    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.
Back to Top