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

Radgrid issue with the shift key in multiselection

2 Answers 176 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nicolas
Top achievements
Rank 1
Nicolas asked on 02 Aug 2011, 01:40 PM

I wanted to know if there is a solution to a radgrid issue with the shift key in multiselection. When i do a multiselection of rows with shift key pressed, the radgrid doesn't throw a postback when the shift key is released.

I was testing some alternatives with the onkeyup event over radgrid but doesnt work well with shift key (dont throw event until ctrl key is pressed) , instead the event it works better with the ctrl key.

However i would appreciate a better solution that doesn't imply handling the key events.

I been follow this issue in this threads

http://www.telerik.com/community/forums/aspnet/grid/how-to-capture-special-keys-ctrl-shift-click-in-server-side.aspx

http://www.telerik.com/community/forums/aspnet-ajax/grid/selection-with-shift-doesn-t-work-as-expected-strange-behaviour.aspx

Thanks in advance.

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 05 Aug 2011, 09:54 AM
Hi Nicolas,

Note that multiselection using the Shift key is a client-side feature of the grid. It does no cause a postback and is used only for client selection. That is why it does not fire the ItemCommand event.
Handling such action on the server would require customizations through client script. You could use the RowSelected client event to capture the selections on the fireCommand() method to fire a custom command on the server and then handle it accordingly in the ItemCommand server event handler of the grid.


Kind regards,
Maria Ilieva
the Telerik team

Browse the vast support resources we have to jump start 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
Nicolas
Top achievements
Rank 1
answered on 05 Aug 2011, 05:04 PM
Thanks for the answer.
 I ask  If pressing ctrl key i'm throwing server side events, why the shift key couldnt do the same?

However i found a solution using the client key events.
When i push shift or ctrl then the attribute "enablepostbackonrowclick" is set to false.
Then when I release the keys the attribute "enablepostbackonrowclick" is set to true,
and throw the postback.

 For the moment the solution seem to serve. If errors are generated in the testing area I'm gonna try your aproach.

.

JS:
function onRadGridKeyDown(sender, eventArgs) {
if ((eventArgs.keyCode == 17 || eventArgs.keyCode == 16) &&
sender.control.ClientSettings.EnablePostBackOnRowClick) {
sender.control.ClientSettings.EnablePostBackOnRowClick =
false;
}
}
function onRadGridKeyUp(sender, eventArgs) {
if (eventArgs.keyCode == 17 || eventArgs.keyCode == 16) {
sender.control.ClientSettings.EnablePostBackOnRowClick =
true;
// if (sender.control.get_selectedItems().length > 0) {
__doPostBack(sender.control.UniqueID,
"select");
// }
}
}

ASPX.CS
   RGrid.Attributes.Add("onkeydown", "onRadGridKeyDown(this,event);");        
   RGrid.Attributes.Add("onkeyup", "onRadGridKeyUp(this,event);");
   RGrid.Attributes.Add("onmouseover", "this.focus();");
   RGrid..Attributes.Add("onFocus", "this.style.outline = '0px';");

 

 

Thanks again

 

 

 

 

 

 

 

 

 

 

 

 

Tags
Grid
Asked by
Nicolas
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Nicolas
Top achievements
Rank 1
Share this question
or