0
votes

I have some difficulties to make a grid with an editor pop , which has inside a collection. I found an example that 's almost like I want, but the grid nested , has a GridEditMode.InCell , and I need to GridEditMode.PopUp .

When I try to change CellEditing PopEditing get the following error: "The Insert data binding setting is required by the insert command . Please specify the Insert action or url in the DataBinding configuration. "

I want the whole object is recorded when the parent object is recorded.

@(Html.Kendo().Grid<EmployeeViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Command(comm =>
{
comm.Edit();
});
columns.Bound(e => e.EmployeeID);
columns.Bound(e => e.FirstName);
columns.Bound(e => e.LastName);
columns.Bound(e => e.Title);        
columns.Bound(e => e.HireDate).Format("{0:d}");
columns.Bound(e => e.Territories)
.ClientTemplate("#=territoriesTemplate(Territories)#");       
})
.Editable(ed=>ed.Mode(GridEditMode.PopUp))
.Pageable()  
.Events(ev=>ev.Edit("onEdit")) 
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)        
.Model(model =>
{
model.Id(e => e.EmployeeID);
model.Field(e => e.EmployeeID).Editable(false);
model.Field(e => e.Territories).DefaultValue(new List<TerritoryViewModel>());
})
.Events(ev=>ev.Change("onDsChange"))
.Read(read => read.Action("Read", "Home"))
.Update(update => update.Action("Update", "Home").Data("serialize")))
)

This is the nested grid that need to be edited with GridEditMode.PopUp

@(Html.Kendo().Grid<TerritoryViewModel>()
.Name("TerritoryGrid")
.Sortable()
.Columns(cols =>
{
cols.Bound(b => b.TerritoryID);
cols.Bound(b => b.TerritoryDescription);
})
 .Editable(ed=>ed.Mode(GridEditMode.InCell))
.AutoBind(false)
.DataSource(ds => ds.Ajax().Model(mo => { 
mo.Id(m => m.TerritoryID);
mo.Field(f => f.TerritoryID).Editable(false);
}))
.ToClientTemplate()
)

Is there any way?

1

1 Answers

0
votes

I assume you found the following demo and you want to change it to use popup editing for the nested Grid. It is possible to make the Grid use Popup editing, however the nested Grid will perform separate request.

If you want to achieve both Popup editing + batch updates you will have to declare your Grid via JavaScript since it provides you with way more flexibility. Or you can use the approach covered in this code library to achieve similar to popup editing + batch updates.