How to Select Multiple Items Without Holding the Ctrl Key

Thread is closed for posting
1 posts, 1 answers
  1. Answer
    Telerik Admin
    Telerik Admin avatar
    1679 posts
    Member since:
    Oct 2004

    Posted 04 Sep 2009 Link to this post

    Requirements

    RadControls for ASP .NET AJAX version

    2008.1.415 +
    .NET version

    2.0 and later

    Visual Studio version

    2005 and later
    Programming language

    Javascript
    Browser support

    all browsers supported by RadControls for ASP .NET AJAX


    PROJECT DESCRIPTION
    Sometimes you may want to enable users to select multiple RadGrid items with the mouse without the need to hold the Ctrl key (by default this is required, similarly to the Windows Explorer behavior). Here is how to do it.

    ASPX

    <asp:Button ID="Button1" runat="server" Text="Deselect all items" 
        OnClientClick="return DeselectItems()" /> 
     
    <br /><br /> 
     
    <telerik:RadGrid 
        ID="RadGrid1" 
        runat="server" 
        AllowMultiRowSelection="true" 
        OnNeedDataSource="RadGrid_NeedDataSource"
        <ClientSettings EnableRowHoverStyle="true"
            <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" /> 
            <ClientEvents OnRowDeselecting="MyRowDeselecting" /> 
        </ClientSettings> 
    </telerik:RadGrid> 
     


    Javascript

    var buttonDeselectFlag = false
     
    function MyRowDeselecting(sender, args) 
        if (!buttonDeselectFlag) 
        { 
            args.set_cancel(true); 
        } 
     
    function DeselectItems() 
        buttonDeselectFlag = true
        var grid = $find("<%= RadGrid1.ClientID %>"); 
        grid.get_masterTableView().clearSelectedItems(); 
        buttonDeselectFlag = false
         
        return false

Back to Top