Hi,
I have this config below for a treelist. You can see that I have enabled drag and drop by setting move to true.
I would expect, when I drag and drop an item from one parent to another, that the "update" action defined in my controller is hit with the model containing the parentId of the new parent, but the "update" action on the controller is not being hit !
What am I missing ?
@(Html.Kendo().TreeList<AccountGroupModel>()
.Name(
"tlAccountGroup"
)
.Toolbar(toolbar =>
{
toolbar.Create();
})
.Columns(columns =>
{
columns.Add().Field(f => f.Name);
columns.Add().Command(c =>
{
c.Edit();
});
})
.Editable(editable => editable.Move(
true
))
.DataSource(datasource =>
datasource
.Model(model =>
{
model.Id(m => m.Id);
model.ParentId(m => m.ParentId);
model.Field(m => m.Name);
})
.Read(read => read.Action(
"AccountGroups_Read"
,
"AccountGrouping"
))
.Create(create => create.Action(
"AccountGroups_Create"
,
"AccountGrouping"
))
.Update(update => update.Action(
"AccountGroups_Update"
,
"AccountGrouping"
))
))
My controller actions look like this:
public
async Task<JsonResult> AccountGroups_Read([DataSourceRequest] DataSourceRequest request)
{
var models = await accountGroupingService.GetAccountGroupsAsync();
return
Json(models.ToTreeDataSourceResult(request, e => e.Id, e => e.ParentId, e => e));
}
public
async Task<JsonResult> AccountGroups_Create([DataSourceRequest] DataSourceRequest request, AccountGroupModel model)
{
if
(model !=
null
&& ModelState.IsValid)
{
model = await accountGroupingService.SaveAccountGroupAsync(model);
}
return
Json(
new
[] {model}.ToTreeDataSourceResult(request, ModelState));
}
public
async Task<JsonResult> AccountGroups_Update([DataSourceRequest] DataSourceRequest request, AccountGroupModel model)
{
if
(model !=
null
&& ModelState.IsValid)
{
model = await accountGroupingService.SaveAccountGroupAsync(model);
}
return
Json(
new
[] { model }.ToTreeDataSourceResult(request, ModelState));
}