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

[Solved] How to insert new data in sub grid

0 Answers 18 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Vincent
Top achievements
Rank 1
Vincent asked on 08 Dec 2011, 07:35 AM

I'm trying to insert a grid in a specific column, But when I press insert button there is not a new row in the nested grid.

My data model is just like this


public class VoCPOI
 {
    public int id { get; set; }
    public string name { get; set; }
    public string no1 { get; set; }
    public string no2 { get; set; }
    public string no3 { get; set; }
 
    public List<FlowSub> subList { get; set; }
}
 
public class FlowSub
{       
    public int subid {get; set;}
    public string subname { get; set; }
    public string subno1 { get; set; }
    public string subno2 { get; set; }
    public string subno3 { get; set; }
}

Grid code in the view page
Html.Telerik().Grid(Model)
       .Name("Grid")
       .DataKeys(keys =>
       {
          keys.Add(p => p.id);
       })                                                               
        .Columns(columns =>
       {
         columns.Command(commands =>
         columns.Bound(o => o.id).Width(30);
         columns.Bound(o => o.name).Width(30);
         columns.Bound(o => o.no1).Width(30);
         columns.Bound(o => o.no2).Width(30);
         columns.Bound(o => o.no3).Width(30);
         columns.Bound(o => o.subList)
             .ClientTemplate(
              Html.Telerik().Grid<Vo.FlowSub>()
                .Name("testsub_<#= id #>")
                .DataKeys(keys =>
                  {
                     keys.Add(ct => ct.subid);
                  })
                     .DataBinding(dataBinding =>
                  {
                     dataBinding.Ajax()
                     .Select("_SelectSubAjaxEditing", "Grid")
                     .Insert("_InsertSubAjaxEditing", "Grid")
                     .Update("_SaveSubAjaxEditing", "Grid")
                     .Delete("_DeleteSubAjaxEditing", "Grid");
                   })
                     .ToolBar(commands =>
                   {
                     commands.Insert().ButtonType(GridButtonType.Image).ImageHtmlAttributes(new { style = "margin-left:0" });
                   })
                     .Columns(innercolumns =>
                   {
                       innercolumns.Bound(ct => ct.subid).Width(20);
                       innercolumns.Bound(ct => ct.subname).Width(20);
                       innercolumns.Bound(ct => ct.subno1).Width(20);
                       innercolumns.Bound(ct => ct.subno2).Width(20);
                      innercolumns.Bound(ct => ct.subno3).Width(20);
                    })
                   .ToHtmlString()
                   );
       })
       .Editable(editing => editing.Mode(GridEditMode.InLine))
       .Render();
Please just give me some advice. Thanks a lot.
Tags
Grid
Asked by
Vincent
Top achievements
Rank 1
Share this question
or