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

Set the Default Editing Mode in RadGrid

4 Answers 727 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 11 Mar 2013, 10:08 PM
This is probably very elementary question but I'm just starting using Telerik RadGrid and while it was very easy to deploy and setup, I'm having a problem to set the grid not to open the edit form the first time it loads. The form always opens up with the first record already in editing mode (file 1), while what I want to set it to is to display the data first and let the end user click on Edit when necessary (file 2). Thanks for any assistance I could get.

4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 12 Mar 2013, 04:47 AM
Hello,

By using below code snippet you can set default editing mode.
<MasterTableView EditMode="EditForms">


Thanks,
Jayesh Goyani
0
Shinu
Top achievements
Rank 2
answered on 12 Mar 2013, 04:59 AM
Hi,

By default the first row will not be opened when the page loads. You can set different edit modes based on your requirement. Check the following help documentation for more.
In Place

Thanks,
Shinu
0
Martin
Top achievements
Rank 1
answered on 12 Mar 2013, 05:29 PM
Maybe I wasn't clear with my question. I chose the EditMode as EditForms. It's just the default, it still opens the Edit Form on the first record. I'm sure this is just a flag somewhere that I need to set. I'm just following the example from
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/templateformupdate/defaultcs.aspx

And here's what I have:
<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0"
    DataSourceID="SqlDataSource1" GridLines="None"
    AutoGenerateEditColumn="False"
    AllowPaging="true" PageSize="20" AllowSorting="true"
    AutoGenerateColumns="false" ShowStatusBar="true"
    AllowAutomaticInserts="true" AllowAutomaticUpdates="true"
    OnItemUpdated="RadGrid1_ItemUpdated"
    OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender" >
  
    <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="OrderId" CommandItemDisplay="None" EditMode="EditForms">
      <Columns>
        <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
        <telerik:GridBoundColumn UniqueName="OrderId" HeaderText="Order #" DataField="OrderId"></telerik:GridBoundColumn>
        <telerik:GridBoundColumn UniqueName="NewSerNo" HeaderText="New S/N" DataField="NewSerNo"></telerik:GridBoundColumn>
        <telerik:GridBoundColumn UniqueName="Completed" HeaderText="Complete?" DataField="Completed"></telerik:GridBoundColumn>
      </Columns>
0
Martin
Top achievements
Rank 1
answered on 12 Mar 2013, 06:59 PM
I finally found the culprit. Just by copying blindly the example, I put RadGrid1.EditIndexes.Add(0);  in the PreRender. After commenting it out, it fixed the issue:

protected void RadGrid1_PreRender(object sender, EventArgs e)
{
   if (!Page.IsPostBack)
   {
     //RadGrid1.EditIndexes.Add(0); 
     RadGrid1.Rebind();
   }
}
Tags
Grid
Asked by
Martin
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Martin
Top achievements
Rank 1
Share this question
or