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

Different template for Edit and Insert?

4 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 18 Aug 2011, 06:41 PM
Hi

Two Questions here. Need answers seperately.

1. Can I have seperate template for Edit and Insert  insead of

<

 

 

EditFormSettings EditFormType="Template" .....>


2. Is is possible to have Inline editing while modifying a record and
<EditFormSettings, Template> way for Insert a new reocord ?  (in the same grid)

Regards



 

4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 18 Aug 2011, 08:12 PM
Hello,

You can hide and show panels in insert/edit mode.

<EditFormSettings EditFormType="Template">
                   <FormTemplate>
                       <asp:Panel ID="Panel1" runat="server" Visible="false">
                       insert mode
                           <asp:CheckBox ID="CheckBox1" runat="server" />
                           <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                           <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                       </asp:Panel>
                       <asp:Panel ID="Panel2" runat="server" Visible="false">
                       edit mode
                           <asp:Label ID="Label1" Text='<%# Eval("ID") %>' runat="server"></asp:Label>
                       </asp:Panel>
                   </FormTemplate>
               </EditFormSettings>
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridEditFormItem && e.Item.IsInEditMode && !e.Item.OwnerTableView.IsItemInserted)
            //if the item is about to edit
            {
                GridEditFormItem editItem = e.Item as GridEditFormItem;
                Panel Panel1 = (Panel)editItem.FindControl("Panel1");
                Panel Panel2 = (Panel)editItem.FindControl("Panel2");
                Panel2.Visible = true;
            }
            if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
            //if the item is about to insert
            {
                GridEditFormItem editItem = e.Item as GridEditFormItem;
                Panel Panel1 = (Panel)editItem.FindControl("Panel1");
                Panel Panel2 = (Panel)editItem.FindControl("Panel2");
                Panel1.Visible = true;
            }
}

As per my knowledge with radgrid your second option is not possible.

Let me know if any concern.


Thanks,
Jayesh Goyani
0
Lee
Top achievements
Rank 1
answered on 19 Aug 2011, 04:13 AM
Hi Jayesh,

I will try your solution, but logically your idea will work for me.

For Telerik Dev. Team.
Is second option is possible? The Point is that while creating new record we want to accept many fields, so here we want 'form' style
of input, but while editing there is only one field that could be changed, and we wanted that if we could do editing inline itself for this.

Regards

0
Jayesh Goyani
Top achievements
Rank 2
answered on 19 Aug 2011, 05:39 AM
Hello,

I will try for second option and inform you.

Thanks,
Jayesh Goyani
0
Jayesh Goyani
Top achievements
Rank 2
answered on 19 Aug 2011, 06:11 AM
Hello,

You can achieve this thing but one condition is there.You are not able to Insert and Edit Items at same time.

Please check my below code and let me know if any concern.

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.InitInsertCommandName)
        {
            RadGrid1.MasterTableView.ClearEditItems();
            RadGrid1.MasterTableView.EditMode = GridEditMode.EditForms;
        }
        else if (e.CommandName == RadGrid.EditCommandName)
        {
            RadGrid1.MasterTableView.IsItemInserted = false;
            RadGrid1.MasterTableView.EditMode = GridEditMode.InPlace;
        }
    }


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Lee
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Lee
Top achievements
Rank 1
Share this question
or