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

Postback when selecting multiple rows with Shift-key

3 Answers 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mikael
Top achievements
Rank 1
Mikael asked on 17 Jan 2013, 02:33 PM
Hi!

I am trying to overcome a limitation in RadGrid (which I think is still around, I am using version 2010.1.309.35):
If AllowMultiRowSelection = true, and the user selects multiple rows by holding down the Shift-key, there is no postback even if

EnablePostBackOnRowClick = true.


There is a workaround described here:
http://stackoverflow.com/questions/7424397/telerik-radgrid-onrowselected-events-all-done-event-for-multiple-selection/14381154#14381154

I have slightly modified the client code to look like this:
function IW_RowSelected(sender, eventArgs) {
    var e = eventArgs.get_domEvent();
    if (!sender.AllowMultiRowSelection || !e.shiftKey) {
        // Multiple row not enabled or shift not pressed, nothing to do
        return;
    }
      
    if (window.rowSelectedTimeout) {
        // If selecting multiple rows, clear the previous row's rowSelectedTimeout
        window.clearTimeout(window.rowSelectedTimeout);
    }
  
    rowSelectedTimeout = window.setTimeout(function() {
        window.rowSelectedTimeout = null;
        alert('rows selected'); // Should force a postback here
    }, 10);
}

And it works fine. There is just one piece missing: How do I force a postback when the "last" row has been selected? Right now, all I do is an "alert('rows selected')", but I need to force a postback so that my server-side code can detect which rows are currently selected.

If it matters, I use an ASP.NET UpdatePanel to get partial updates.

Thanks!
/Fredrik

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 22 Jan 2013, 09:36 AM
Hi Fredrik,

You could call rebind() function instead showing alert message. Check out the following code snippet.
$find("<%= RadGrid1.ClientID %>").get_masterTableView().rebind();

Kind regards,
Kostadin
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.
0
Mikael
Top achievements
Rank 1
answered on 22 Jan 2013, 01:08 PM
Thanks for your reply!

The rebind() method works in a way (a postback will be posted to the server). However, this will cause the grid to lose its selection state, at least with the server-side code I currently have. Perhaps I could code around this on the server-side, but it would make the code more complex.

I was hoping there is a way to mimic the exact same behaviour as when the user selects a single row.

Example:
1. The user has previously selected row A..
2. The user selects row B. This causes a postback, and the selected rows (as detected on the server side) are  A and B.
This is the normal behaviour.
3. While holding down the Shift-key, the user clicks row E. This should selects rows A, B, C, D and E on the client. This should cause a postback, and the selected rows (as detected on the server side) are A, B, C, D and E.

Hope I make myself understood.
Thanks!
/Fredrik
0
Kostadin
Telerik team
answered on 25 Jan 2013, 03:00 PM
Hi Fredrik,

Our developers have already addressed this issue and the selected event is properly executing with the current version of RadControls.

Regards,
Kostadin
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
Mikael
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Mikael
Top achievements
Rank 1
Share this question
or