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

RadGrid with contexMenu

4 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jan
Top achievements
Rank 1
Jan asked on 03 Sep 2012, 01:37 PM
Hi,
I am using RadContextMenu on RadGrid.

I have a little problem with selection row. When I activate context menu with right click on grid, that row select which is fine.
But when I select another row previous row is still selected. 

How do I deselect that row?

thank you,
Jan

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Sep 2012, 03:39 AM
Hi,

I guess you have set the RadGrid property AllowMultiRowSelection to true. Try setting this property to false.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowSelection="false" >

Thanks,
Shinu.
0
Jan
Top achievements
Rank 1
answered on 04 Sep 2012, 06:26 AM
Hi Shinu,
If I disable AllowMultiRowSelection, then I also disable "shift+click" multiselection.

Is there any other way?
0
Accepted
Shinu
Top achievements
Rank 2
answered on 05 Sep 2012, 04:01 AM
Hi Jan,

Try adding the following javascript inside the ClientEvent 'OnRowContextMenu' for allowing only one row selection at a time. AllowMultiRowSelection is set to true. Here is the sample code i tried.

Javascript:
<script type="text/javascript">
    function RowContextMenu(sender, eventArgs)
    {
        var gridSelectedItems = sender.get_masterTableView().get_selectedItems();
        for (var i = 0; i < gridSelectedItems.length; i++)
        {
            if (gridSelectedItems[i].get_selected())
            {
                gridSelectedItems[i].set_selected(false);
            }
 
        }  
       //code for context menu
    }
</script>

Thanks,
Shinu.
0
Jan
Top achievements
Rank 1
answered on 05 Sep 2012, 06:42 AM
I have customized your JavaScript and get to solution.
Thank you Shinu.
Tags
Grid
Asked by
Jan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jan
Top achievements
Rank 1
Share this question
or