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

Right Click Multiselects Rows

5 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
dave
Top achievements
Rank 1
dave asked on 07 Feb 2012, 07:43 PM

I am using the version 2011.3.1305.35 of the RadGrid and experiencing some strange behavior when the grid is right clicked. Occasionally when a user right clicks the gird to bring up a context menu the row that was right clicked will be selected in addition to any rows that were previously selected. The other times it just displays the context menu without selecting the rows. It seems to be intermittent and I cannot consistently reproduce results. I do not want the additional rows to be selected. Is there any way to trap how a row became selected? The domEvent property of the onrowselecting event args does not look like it has what I need.

 
Here is how i have the grid configured and the code that displays the context menu:

<telerik:RadGrid ID="tGrid" runat="server" AllowPaging="True" AllowCustomPaging="true" PageSize="500"
                AllowSorting="True" AutoGenerateColumns="False" CellSpacing="0"
                OnNeedDataSource="tGrid_NeedDataSource" AllowMultiRowSelection="true"
 OnItemCreated="tGrid_ItemCreated" >
                <PagerStyle AlwaysVisible="True" Position="Top"/>
                
                <MasterTableView Width="100%" DataKeyNames="schedID" ClientDataKeyNames="schedID">
                    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>                   
                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
                    <Columns>
                        ...
                    </Columns>
 
                    <EditFormSettings>
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                        </EditColumn>
                    </EditFormSettings>
                </MasterTableView>
                <ClientSettings EnableRowHoverStyle="true">
                    <Selecting AllowRowSelect="True" />
                    <ClientEvents OnGridCreated="GridCreated"
                                  OnRowContextMenu="RowContextMenu" OnRowDblClick="tGrid_RowDblClick" />
                    <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                </ClientSettings>                          
                <FilterMenu EnableImageSprites="false"></FilterMenu>               
            </telerik:RadGrid>

 

function RowContextMenu(sender, eventArgs)
{
    var contextmenu = $find("<%=DisplayContextMenu.ClientID %>");
     
    //get_domEvent returns a reference to the DOM event that caused the clicking
    var domEvent = eventArgs.get_domEvent();
 
    //If we're in an input field or a link, just ignore this request for a context menu
    if (domEvent.target.tagName == "INPUT" || domEvent.target.tagName == "A")
        return;
                   
    contextmenu.show(domEvent);
     
    domEvent.cancelBubble = true;
    domEvent.returnValue = false;
 
    if (domEvent.stopPropagation)
    {
        domEvent.stopPropagation();
        domEvent.preventDefault();
    }
 
    if(sender.get_id() == "<%= tGrid.ClientID %>")
        rightClickedRowId = eventArgs.getDataKeyValue("schedID")                
}


Thanks Dave

5 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 09 Feb 2012, 09:44 AM
Hi Dave,

Are you using the drag-to-select feature of the grid? Does EnableDragToSelect=false make any difference? Do let us know if it is a feasible work-around for you.

Regards, Tsvetoslav
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
dave
Top achievements
Rank 1
answered on 09 Feb 2012, 08:39 PM
Yes, that does seem to help. However, when I use the shift key to select multiple rows the contents on the page gets selected as well. It does not look as nice as it did when the EnableDragToSelect was set to true. Is there any way to prevent the page selection?

Thanks,
Dave
0
Tsvetoslav
Telerik team
answered on 10 Feb 2012, 06:10 AM
Hello Dave,

Our development team will be looking into a possible fix for the issue and we will be getting back to you with further information. 

Regards,
Tsvetoslav
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Tsvetoslav
Telerik team
answered on 10 Feb 2012, 06:10 AM
Hello Dave,

Our development team will be looking into a possible fix for the issue and we will be getting back to you with further information. 

Regards,
Tsvetoslav
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Tsvetoslav
Telerik team
answered on 23 Feb 2012, 04:18 PM
Hi Dave,

The issue has just been fixed and the fix will be available in the next latest internal build of the controls that's coming up on Tuesday next week. Thanks for turning our attention to this problem. I have updated your telerik points.


All the best, Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
dave
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
dave
Top achievements
Rank 1
Share this question
or