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

Select multiple rows onclick?

8 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Software
Top achievements
Rank 1
Software asked on 05 Jun 2008, 09:06 PM
I have a radgrid where I want the user to be able to just click to select multiple rows.  Not click and drag, and not ctrl-click.  Instead, every time they click a row it either selects that row, if it's not already selected - or it deselects it if it's currently selected.  So in the end you end up with a grid with multiple rows selected. 

I would need to intercept the rowclick because I need to check to see if there are 6 rows selected yet.  Once there are 6 rows selected, I'll need to grab the values from the 6 rows and redirect the user to another page where I use those values.

Is this possible with RadGrid?  I currently do this with a GridView, but it's all done on the client side...  It would be nice to be able to use some of the built-in functionality in RadGrid to accomplish this, but I've been working on it for a couple hours and haven't been able to get it to respond the way I thought it would...

Thanks for the help!

Eddie

8 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 06 Jun 2008, 06:36 AM
Hi Eddie,

You can use the client-side api of the control, and more specifically the rowClick event handler, to handle the selection via the SelectItem method, for example.
I hope this suggestion helps.

All the best,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Software
Top achievements
Rank 1
answered on 06 Jun 2008, 03:51 PM
What would I need to set my Selecting options to in the RadGrid?  Specifically, what should I set these options to:

AllowMultiRowSelection
EnablePostBackOnRowClick
EnableDragToSelectRows

Thanks for the help!
Eddie

0
Software
Top achievements
Rank 1
answered on 06 Jun 2008, 08:07 PM
Hi Yavor,

Also, how do I persist the selected items so that when a user clicks a row, it doesn't deselect all of the other items?  Is there an example somewhere so I can see how it's done?  I've been trying to get this working all day and still can't quite get it...

Thanks for your help!

Eddie
0
Shinu
Top achievements
Rank 2
answered on 09 Jun 2008, 07:47 AM
Hi Eddie,

Try the following code snippet.

ASPX:
<telerik:radgrid id="RadGrid1" runat="server"   AllowMultiRowSelection="true"   > 
            <ClientSettings EnablePostBackOnRowClick="true" > 
             <Selecting  AllowRowSelect="true" /> 
            </ClientSettings> 

Client-side row selection

Shinu.
0
Software
Top achievements
Rank 1
answered on 09 Jun 2008, 02:47 PM
Thanks Shinu, but that results in thesame thing - if the user doesn't ctrl-click on the rows then each click deselects any other selected row.  I want the user to be able to just click each row and they all stay selected, unless they click on a row again, in which case it would be deselected.  Is there an example of that functionality anywhere?
0
Yavor
Telerik team
answered on 10 Jun 2008, 06:33 AM
Hi Eddie,

Although there is no straightforward solution to the functionality that you described initially, you can use the client side api of the control to simulate it. For example, the rowDeselecting event handler can be cancelled out conditionally, to disallow the default behavior of the control to deselect the previous rows when you click on a single row:

.Js
 function rowDeselecting(sender, eventArgs)  
        {  
        eventArgs.set_cancel(true);  
        } 


Regards,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Amjad
Top achievements
Rank 1
answered on 06 Sep 2012, 10:47 AM
Hello Yavor;

worked fine with me but the problem that if the user would like to deselect an item he cant !

any ideas ?
0
Radoslav
Telerik team
answered on 11 Sep 2012, 06:42 AM
Hi Amjad,

Please check out the following code library which demonstrates the desired functionality:
http://www.telerik.com/community/code-library/aspnet-ajax/grid/radgrid-client-side-toggle-selection-with-server-side-persisting-of-the-selected-items-after-sorting-filtering-and-paging.aspx

I hope this helps.

Kind regards,
Radoslav
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
Software
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Software
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Amjad
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or