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

RadGrid Change EditMode OnRowDblClick

4 Answers 445 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mahmoud
Top achievements
Rank 1
Mahmoud asked on 26 Jul 2013, 01:32 PM
Hi,

I have a RadGrid with EditForm Template for Editing.
for Example:
I want to have:
 * When I double click a row it has to Change Editmode to:
<MasterTableView EditMode="InPlace"
Like this:
function RowDblClick(sender, eventArgs) {
      // insert Code here to change EditMode to EditMode="InPlace"
      // then open the row for editing
      editedRow = eventArgs.get_itemIndexHierarchical();
      $find("<%= RadGrid1.MasterTableView.ClientID %>").editItem(editedRow);
    }

 hence, the Default mode is the EditForm Template, so when I click on Edit button it will open the form for editing.

any Help it will be apperciated,
Thanks

4 Answers, 1 is accepted

Sort by
0
Mahmoud
Top achievements
Rank 1
answered on 29 Jul 2013, 07:09 PM

any Help here ...

Thanks,
0
Accepted
Princy
Top achievements
Rank 2
answered on 30 Jul 2013, 09:41 AM
Hi Mahmoud,

I'm afraid your requirement cannot be completely achieved in the client side.Here is another approach please try the below code snippet.

ASPX:
<telerik:RadGrid ID="RadGrid1"  AutoGenerateColumns="false"
    AutoGenerateEditColumn="true" runat="server" OnItemCommand="RadGrid1_ItemCommand" AllowPaging="true">
    <MasterTableView EditMode="InPlace">
        <Columns>
            <telerik:GridBoundColumn DataField="OrderID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="EmployeeID">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings>
        <ClientEvents OnRowDblClick="OnRowDblClick" />
    </ClientSettings>
</telerik:RadGrid>

C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    if (e.CommandName == "DoubleClickEdit")
    {
        GridDataItem item = RadGrid1.Items[e.CommandArgument.ToString()];
        item.Edit = true;
        RadGrid1.MasterTableView.EditMode = GridEditMode.InPlace;
        RadGrid1.Rebind();
    }
    else if (e.CommandName == RadGrid.EditCommandName)
    {
        RadGrid1.MasterTableView.EditMode = GridEditMode.EditForms;
    }
}

JS:
<script type="text/javascript">
    function OnRowDblClick(sender, eventArgs) {
        var grid = $find("<%=RadGrid1.ClientID %>");
        var master = grid.get_masterTableView();
        editedRow = eventArgs.get_itemIndexHierarchical();
        master.fireCommand("DoubleClickEdit", editedRow);
    }
</script>

Let me know if any concern.

Thanks,
Princy
0
Accepted
Konstantin Dikov
Telerik team
answered on 30 Jul 2013, 03:51 PM
Hi Mahmoud,

In addition to Princy's answer I may suggest you have a look at this thread with the exact requirements as yours. The attached project there covers some special cases by closing any open edit forms before switching to "InPlace" edit mode on double click.

 

Best Regards,
Konstantin Dikov
Telerik
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 the blog feed now.
0
Mahmoud
Top achievements
Rank 1
answered on 30 Jul 2013, 07:06 PM
Hi PrincyKonstantin

Thanks for the Reply.
both Solutions have the same approach , and both working perfect as expected.

Thanks,
Tags
Grid
Asked by
Mahmoud
Top achievements
Rank 1
Answers by
Mahmoud
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Konstantin Dikov
Telerik team
Share this question
or