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

Multi Select With Using Ctrl?

8 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeremy Yoder
Top achievements
Rank 1
Jeremy Yoder asked on 12 Oct 2010, 10:21 PM

With multi select turned on, I know I can select multiple rows by holding down ctrl, but can I make the grid do the same without holding down ctrl? (Meaning, clicking a row will either select or deselect it, without altering the state of other rows, just like clicking GridClientSelectColumn does.)

8 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 13 Oct 2010, 08:56 AM
Hi Jeremy,

How to Select Multiple Items Without Holding the Ctrl Key code library demonstrates how you can achieve the desired functionality.

Give it a try and see if it helps.

Regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
sculver
Top achievements
Rank 1
answered on 16 Nov 2010, 12:06 AM
I think I found a much better way (at least using version 2010 Q3), for anyone else out there looking.

The following will give you functionality where it will select each as you click on them, and still deselect them if you click on a selected item again.  It also will function with the header row checkbox to toggle them all on or off.

Just tie all of these into the Grid's Client event as appropriate, along with the normal other properties to get the built-in selection to work:
var originalClickedRowState = null;
var clickedRow = null;
 
function rgGrid_OnRowClick(sender, args) {
    clickedRow = args.get_gridDataItem();
    originalClickedRowState = args.get_gridDataItem().get_selected();
}
 
function rgGrid_OnRowDeselecting(sender, args) {
    if (clickedRow != null && clickedRow != args.get_gridDataItem()) {
            args.set_cancel(true);
    }
}
 
function rgGrid_OnRowSelecting(sender, args) {
    if (clickedRow == args.get_gridDataItem() && originalClickedRowState) {
        args.set_cancel(true);
        originalClickedRowState = null;
        clickedRow = null;
    }
}
 
function rgGrid_OnRowSelected(sender, args) {
    originalClickedRowState = null;
    clickedRow = null;
}
0
Pavlina
Telerik team
answered on 16 Nov 2010, 12:56 PM
Hi Stephen,

Thank you for sharing

Thank you for sharing your solution with the community. I am sure it would be useful for other members who are searching such functionality.

Kind regards,
Pavlina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Jeremy Yoder
Top achievements
Rank 1
answered on 16 Nov 2010, 03:14 PM

Thanks for the idea. So is the cancelDeselection variable used elsewhere? Or is it predefined by telerik?

Also, to Teleirk admins, I just noticed my thread title says "With" but it should be "Without". I can't edit it, but maybe you'll want to so others can find this thread more easily.
0
sculver
Top achievements
Rank 1
answered on 16 Nov 2010, 03:23 PM
My apologies, that was left over code from something else I was trying before I got my final solution.  Thanks for pointing it out for me.  I have updated the original post with the new code (that if ... else has been removed - it is not needed).
0
Gum
Top achievements
Rank 1
answered on 08 Mar 2012, 12:21 PM
Can you please show the full code for this.
I am getting errors with this code using both:
 Telerik.WebControls in RadGrid.Net2
Telerik.Web.UI in Telerik.Web.UI

thanks
0
Gum
Top achievements
Rank 1
answered on 16 Mar 2012, 10:09 AM
Hi,

How do you make this code work with IE8 and IE7 as the event order is different from chrome and firefox.

chrome and firefox event fire order:

"Click on row to select it"
Click
Selecting
Selected

"click on another row to select it"
Click
deselecting
deselected
selecting

IE8 and IE7
"Click on row to select it"
Selecting
Selected
Click

"click on another row to select it"
deselecting
deselected
selecting
Click
0
Michael
Top achievements
Rank 1
answered on 17 Sep 2014, 02:41 PM
Thanks for this, works great for me!
Tags
Grid
Asked by
Jeremy Yoder
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
sculver
Top achievements
Rank 1
Jeremy Yoder
Top achievements
Rank 1
Gum
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Share this question
or