I've a RadTextBox in EditItemTemplate of a RadGrid. In edit mode, while the cursor is in the RadTexBox I like to hit enter/return key on the keyboard and trigger the server side UpdateCommand event of RadGrid. Can someone please advice how I can achieve this? Thanks.
3 Answers, 1 is accepted
0
Sebastian
Telerik team
answered on 08 Oct 2010, 09:22 AM
Hello HarryM,
To attain the functionality you are after, consider intercepting the OnKeyPress event of the grid, detect whether the returned key code is 13 (as demonstrated in the javascript key press handler on this example) and invoke the updateItem(gridItem) client method to trigger update command.
Additionally, you may be happy to know that for the next major version Q3 2010 this will be automatically handled by RadGrid (for edit and insert operation) when you enable the keyboard navigation feature of the control.
Kind regards,
Sebastian
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
Thanks for the quick response Sabastian. I did try your suggest solution. I have this javascript code to handle the update but somehow eventArgs.get_itemIndexHierarchical() is not working. Can you please point out why? Thanks
function OnKeyPressGrid(sender, eventArgs)
{
if (eventArgs.get_keyCode() == 13) {
var index = eventArgs.get_itemIndexHierarchical();
alert(index);
var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
masterTable.updateItem(masterTable.get_dataItems()[index]);
}
}
0
Sebastian
Telerik team
answered on 11 Oct 2010, 02:03 PM
Hello HarryM,
The index of the edited item is not passed through the args inside the OnKeyPress client handler.
You will need to store the index of the edited item (e.Item.ItemIndex) in a global javascript variable (for example) intercepting the edit command of the grid by wiring its ItemCommand server event (when e.CommandName is RadGrid.EditCommandName). Then you can fetch the edited row index from that variable to use it for the updateItem client method.
Try this out and let me know how it goes.
Best regards,
Sebastian
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