This is a migrated thread and some comments may be shown as answers.
EditItemTemplate for RadGrid ?
3 Answers 282 Views
This is a migrated thread and some comments may be shown as answers.
RadTony
Top achievements
Rank 1
RadTony asked on 05 Feb 2010, 04:07 PM
Hi Experts,

         For the framework components like <asp:gridview> there exists <EditItemTemplate> ... How can I get that with Telerik ?
What I try to do is to avoid "blinking " the grid when I click on Edit button ... So, I want to define a fixed width for the cells (wether they are in edit mode or normal mode).
    <asp:GridView ID="GridView1" runat="server"
    <Columns> 
        <asp:TemplateField> 
            <ItemTemplate> 
                <asp:TextBox Width="200px" runat="server" ID="aaa"></asp:TextBox> 
            </ItemTemplate>             
            <EditItemTemplate> 
                <asp:TextBox Width="200px" runat="server" ID="aaa"></asp:TextBox> 
            </EditItemTemplate> 
        </asp:TemplateField> 
    </Columns> 
    </asp:GridView> 


        How can I do this with RadGrid ? This is indeed a simple question for you people ... 

        When I edit, I would like to limit the height of the cells. What I'm doing actually is :
 
    protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem && e.Item.IsInEditMode) 
        { 
            TextBox tbLastName = (e.Item as GridDataItem)["LastName"].Controls[0] as TextBox; 
            tbLastName.Height = Unit.Pixel(12); 
            //tbLastName.Width = Unit.Pixel(10); 
            tbLastName.Style["Font-size"] = "11px"; 
            tbLastName.Style["padding-top"] = "1px"; 
 
            TextBox tbFirstName = (e.Item as GridDataItem)["FirstName"].Controls[0] as TextBox; 
            tbFirstName.Height = Unit.Pixel(12); 
            tbFirstName.Style["Font-size"] = "11px"; 
            tbFirstName.Style["padding-top"] = "1px"; 
 
            TextBox tbTitle = (e.Item as GridDataItem)["Title"].Controls[0] as TextBox; 
            tbTitle.Height = Unit.Pixel(12); 
            tbTitle.Style["Font-size"] = "11px"; 
            tbTitle.Style["padding-top"] = "1px"; 
        } 
    } 
 

Thanks in advance,
RadTony The Newbie

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 08 Feb 2010, 05:05 AM
Hi,

You can make use of the GridTemplateColumn of the grid for the desired template feature.You can refer to the demo link below for a detailed explanation on the same.

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx

Hope this helps.Do let me know if there are any more queries.

Thanks,
Princy
0
MTC
Top achievements
Rank 1
answered on 20 Mar 2013, 09:01 AM
Hi ...
I need to make edit template invisible or visible dynamically based upon certain conditions. How can I make it?????
0
Shinu
Top achievements
Rank 1
answered on 20 Mar 2013, 09:07 AM
Hi,

You can hide the controls in edit mode as shown below.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem item = (GridEditableItem)e.Item;
             if(condition)
            RadComboBox combo = (RadComboBox)item.FindControl("RadComboBox1");
            combo.Visible = false;
        }
}

Thanks,
Shinu
Tags
Grid
Asked by
RadTony
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
MTC
Top achievements
Rank 1
Shinu
Top achievements
Rank 1
Share this question
or