Telerik:单击 "canceledit" 打开 deleteConfirm-Dialog
Telerik: Click on "canceledit" opens deleteConfirm-Dialog
我在我的视图中包含了 TreeList-Component,如下所示:
@(Html.Kendo().TreeList<TaxonomyTreeNodeViewModel>()
.Name("treelist")
.Toolbar(
toolbar =>
{
/*toolbar init*/
}
)
.Columns(columns =>
{
columns.Add().Field(e => e.GermanTranslation);
columns.Add().Field(e => e.Sequence);
columns.Add().Command(c =>
{
if (!Model.IsPublished)
c.Edit();
if (!Model.IsPublished)
c.Destroy();
if (!Model.IsPublished)
c.CreateChild();
});
})
.Editable(editable => editable.Move(true))
.Reorderable(true)
.Filterable()
.Sortable()
.Editable()
.DataSource(dataSource => dataSource
.Read(read => read.Action("All", "DashboardTaxonomy"))
.Update(update => update.Action("Update", "DashboardTaxonomy"))
.Create(create => create.Action("Create", "DashboardTaxonomy"))
.Destroy(destroy => destroy.Action("Destroy", "DashboardTaxonomy"))
.ServerOperation(false)
.Model(m =>
{
m.Id(f => f.Id);
m.ParentId(f => f.ParentId);
m.Field(f => f.EnglishTranslation);
m.Field(f => f.Sequence);
})
)
.Events(
events =>
{
events.DataBound("TaxonomyTreeWidget.dataBound");
}
)
)
}
我的模特:
public class TaxonomyTreeNodeViewModel
{
public string Id { get; set; }
public string ParentId { get; set; }
[Display(Name = "Reihenfolge")]
public int Sequence { get; set; }
[Display(Name = "Deutsche Bezeichnung")]
public string GermanTranslation { get; set; }
[Display(Name = "Englische Bezeichnung")]
public string EnglishTranslation { get; set; }
[Display(Name = "Versionsnummer")]
public int Version { get; set; }
[Display(Name = "Veröffentlicht")]
public bool Published { get; set; }
/*[...]*/
}
TreeList 呈现预期结果。当我点击编辑按钮时,我可以编辑并保存数据行。
但是,当我取消编辑时,会出现一个确认对话框(测试:"Are you sure you want to delete this record?"),带有数据命令="canceledit" 的按钮会从 DOM 和数据-命令="destroy"-出现按钮。
请帮忙,
谢谢!
我通过一些小的变通解决了这个问题。以下 TypeScript 覆盖了 kendoTreelist
的取消方法:
$(() => {
$('body').on('click', '#treelist', () => {
$('#treelist').data('kendoTreeList').bind('cancel', e => {
e.preventDefault();
$('#treelist').data('kendoTreeList').dataSource.read();
});
});
});
因此,如果用户触发取消按钮,树列表将设置为其初始状态。
我在我的视图中包含了 TreeList-Component,如下所示:
@(Html.Kendo().TreeList<TaxonomyTreeNodeViewModel>()
.Name("treelist")
.Toolbar(
toolbar =>
{
/*toolbar init*/
}
)
.Columns(columns =>
{
columns.Add().Field(e => e.GermanTranslation);
columns.Add().Field(e => e.Sequence);
columns.Add().Command(c =>
{
if (!Model.IsPublished)
c.Edit();
if (!Model.IsPublished)
c.Destroy();
if (!Model.IsPublished)
c.CreateChild();
});
})
.Editable(editable => editable.Move(true))
.Reorderable(true)
.Filterable()
.Sortable()
.Editable()
.DataSource(dataSource => dataSource
.Read(read => read.Action("All", "DashboardTaxonomy"))
.Update(update => update.Action("Update", "DashboardTaxonomy"))
.Create(create => create.Action("Create", "DashboardTaxonomy"))
.Destroy(destroy => destroy.Action("Destroy", "DashboardTaxonomy"))
.ServerOperation(false)
.Model(m =>
{
m.Id(f => f.Id);
m.ParentId(f => f.ParentId);
m.Field(f => f.EnglishTranslation);
m.Field(f => f.Sequence);
})
)
.Events(
events =>
{
events.DataBound("TaxonomyTreeWidget.dataBound");
}
)
)
}
我的模特:
public class TaxonomyTreeNodeViewModel
{
public string Id { get; set; }
public string ParentId { get; set; }
[Display(Name = "Reihenfolge")]
public int Sequence { get; set; }
[Display(Name = "Deutsche Bezeichnung")]
public string GermanTranslation { get; set; }
[Display(Name = "Englische Bezeichnung")]
public string EnglishTranslation { get; set; }
[Display(Name = "Versionsnummer")]
public int Version { get; set; }
[Display(Name = "Veröffentlicht")]
public bool Published { get; set; }
/*[...]*/
}
TreeList 呈现预期结果。当我点击编辑按钮时,我可以编辑并保存数据行。
但是,当我取消编辑时,会出现一个确认对话框(测试:"Are you sure you want to delete this record?"),带有数据命令="canceledit" 的按钮会从 DOM 和数据-命令="destroy"-出现按钮。
请帮忙,
谢谢!
我通过一些小的变通解决了这个问题。以下 TypeScript 覆盖了 kendoTreelist
的取消方法:
$(() => {
$('body').on('click', '#treelist', () => {
$('#treelist').data('kendoTreeList').bind('cancel', e => {
e.preventDefault();
$('#treelist').data('kendoTreeList').dataSource.read();
});
});
});
因此,如果用户触发取消按钮,树列表将设置为其初始状态。