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

Hide edit panel

1 Answer 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hitesh
Top achievements
Rank 1
Hitesh asked on 01 Apr 2012, 01:25 AM
Hi,

I'm trying to figure out how to hide the edit panel after the user presses entered.  The edit panel is what comes up below the selected row with the update and cancel button.  I just want the postback to occur after the user presses enter to get the row that is currently being worked on.  I'm creating the detail of the record below the grid.   This sounds simple, but I just can't figure it out. Seems like I need to set something to false.

I have the following settings on in Client Settings tag:

<ClientSettings EnablePostBackOnRowClick="true"   Selecting-AllowRowSelect="true" AllowKeyboardNavigation="true" />

Thank you,
 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 04 Apr 2012, 02:00 PM
Hello Hitesh,

Thank you for contacting us.

I suppose you want to apply changes on pressing the Enter key when RadGrid is in edit mode.
In order to achieve that you have two options:
  • use the OnKeyPress event to update your grid:
<ClientSettings ... AllowKeyboardNavigation="true" />
<
ClientEvents ... OnKeyPress="onKeyPress" />
JavaScript:
function onKeyPress(sender, args) {
   if (args.get_keyCode() != 13)
      return;
  
    var el = Telerik.Web.UI.Grid.GetCurrentElement(args.get_domEvent());
    if (!el.id) return;
    var dataItems = $find("RadGrid1").get_masterTableView().get_dataItems();
    var isInEditMode = false;
             
    for (var i = 0; i < dataItems.length; i++) {
         if (dataItems[i].get_isInEditMode()) {
            isInEditMode = true;
              break;
                }
        }
            //handles InPlace edit mode
    if ($(el).parents("tr").attr("id") && $(el).parents("tr").attr("id") != "" && isInEditMode) {
       sender.get_masterTableView().updateItem($(el).parents("tr")[0]);
            } else {
            //handles EditForms edit mode           
    var editFrom = $(el).parents("tr:has(div)");
       if (editFrom.length > 0 && editFrom.prev("tr").attr("id") != "") {
           sender.get_masterTableView().updateItem(editFrom.prev("tr")[0]);
         }
     }
 }
  • implement an alternative approach using the code-behind, described in the following post:

DefaultButton in EditMode

Hope this helps. Feel free to turn to us if you need further assistance.

Greetings,
Eyup
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
Hitesh
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or