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

Open FormTemplate Insert From Grid Cell

3 Answers 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff Grol
Top achievements
Rank 1
Jeff Grol asked on 09 Jun 2010, 11:29 PM
Hello,
I have a hierarchial grid in which I would like to open the insert form template from an image button/link button in a grid row/cell but in all of the documentation it appears that it needs to open from the CommandItem Template.   Is there a way to do this?  The row that gets inserted would actually be a child record for the row on which the image button is selected, so I need it to have some context available in the insert command event to identify the parent record for which to tie the child record to.   Assuming the answer to my first question is "Yes", is there a way to obtain a key value from the correct row in the insert command event?

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 10 Jun 2010, 08:35 AM
Hello Jeff,

You can add a LinkButton in the MasterTableView for inserting a record for child table. In the ItemCommand event handler check for the CommandName and get the DataKeyValue for that row to identify the corresponding parent record. Then set the IsItemInserted property of inner tableview as "true" to put it in insert mode. Sample code is given below.

ASPX:
 <telerik:GridTemplateColumn> 
      <ItemTemplate> 
            <asp:LinkButton ID="LinkButton1" CommandName="InsertChild" runat="server">Insert</asp:LinkButton> 
      </ItemTemplate> 
 </telerik:GridTemplateColumn> 

C#:
 
 protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
    { 
        if (e.CommandName == "InsertChild"
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            string id = item.GetDataKeyValue("EmployeeID").ToString();  //get keyvalue 
            GridTableView tableView = (GridTableView)item.ChildItem.NestedTableViews[0]; 
            tableView.IsItemInserted = true
            tableView.Rebind(); 
        } 
    } 

Regards,
Shinu.


0
Jeff Grol
Top achievements
Rank 1
answered on 10 Jun 2010, 02:56 PM
Thank you very much.  I think this will do what we need.  One additional question: Can you open the insert formtemplate under a grid row like you can in edit mode, or is it only possible to open the form at the top/bottom of the grid?
0
Radoslav
Telerik team
answered on 15 Jun 2010, 12:36 PM
Hello Jeff,

You could display the insertion form only above or below the active grid page or visualize  the form on the current, first or the last page (which is the default behavior on init insert). For more information please check out the following online documentation article:
http://www.telerik.com/help/aspnet-ajax/grdcustomizeinsertformposition.html

All the best,
Radoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Jeff Grol
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jeff Grol
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or