我有一个包含一些列的剑道网格。列出我的数据的索引页面。我的问题是,当我单击“编辑”按钮时,整行都变成了html标签。有没有人知道这个问题。我的代码如下。
@(Html.Kendo().Grid<kendoUsing.Models.ProductViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(product => product.ProductID).Width(50);
columns.Bound(product => product.ProductName);
columns.Bound(product => product.UnitsInStock).Width(50);
columns.Command(commands =>
{
commands.Edit();
commands.Destroy(); // The "destroy" command removes data items.
}).Title("Commands").Width(200);
})
.DataSource(dataSource =>
dataSource.Ajax()
.Batch(true) // Enable batch updates.
.Model(model =>
{
model.Id(product => product.ProductID); // Specify the property which is the unique identifier of the model.
model.Field(product => product.ProductID).Editable(false); // Make the ProductID property not editable.
})
.Create(create => create.Action("Products_Create", "Home")) // Action method invoked when the user saves a new data item.
.Read(read => read.Action("Products_Read", "Home")) // Action method invoked when the grid needs data.
.Update(update => update.Action("Products_Update", "Home")) // Action method invoked when the user saves an updated data item.
.Destroy(destroy => destroy.Action("Products_Destroy", "Home")) // Action method invoked when the user removes a data item.
)
.Pageable()
)
答案 0 :(得分:0)
使用网格时应定义可编辑网格项目。
.Editable(editable =>
{
editable.Mode(GridEditMode.PopUp);
})
所以应该像这样:
@(Html.Kendo().Grid<kendoUsing.Models.ProductViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(product => product.ProductID).Width(50);
columns.Bound(product => product.ProductName);
columns.Bound(product => product.UnitsInStock).Width(50);
columns.Command(commands =>
{
commands.Edit();
commands.Destroy(); // The "destroy" command removes data items.
}).Title("Commands").Width(200);
})
.DataSource(dataSource =>
dataSource.Ajax()
.Batch(true) // Enable batch updates.
.Model(model =>
{
model.Id(product => product.ProductID); // Specify the property which is the unique identifier of the model.
model.Field(product => product.ProductID).Editable(false); // Make the ProductID property not editable.
})
.Create(create => create.Action("Products_Create", "Home")) // Action method invoked when the user saves a new data item.
.Read(read => read.Action("Products_Read", "Home")) // Action method invoked when the grid needs data.
.Update(update => update.Action("Products_Update", "Home")) // Action method invoked when the user saves an updated data item.
.Destroy(destroy => destroy.Action("Products_Destroy", "Home")) // Action method invoked when the user removes a data item.
)
.Pageable()
.Editable(editable =>
{
editable.Mode(GridEditMode.PopUp);
})
)