我把这个Kendo UI网格绑定到一张桌子上。此网格具有活动的批量编辑功能。这意味着我可以直接在网格单元上更改值并保存。批量更新Kendo UI Grid动态更改值
我想完成的是通过每行更改客户端一些列中的显示值来运行循环,然后点击保存按钮。
这是我在我的网格:
@(Html.Kendo().Grid<TokenEncrypt.Models.SellerEntity>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.Name);
columns.Bound(c => c.EntityId);
columns.Bound(c => c.SellerEntityTypeId);
columns.Bound(c => c.CompanyId);
columns.Bound(c => c.IsActive);
columns.Bound(c => c.AwsAccessKeyId);
columns.Bound(c => c.SecretAccessKey);
})
.HtmlAttributes(new { style = "height: 500px;" })
.Scrollable()
.Editable(editable => editable.Mode(GridEditMode.InCell))
.ToolBar(toolbar =>
{
toolbar.Save();
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("SellerEntities_Read", "Grid"))
.Update(update => update.Action("SellerEntities_Ubdate", "Grid"))
.Batch(true)
.Model(model =>
{
model.Id(c => c.EntityId);
}
)
)
)
这是我在我的循环:(我没有线索如何删除值,并把在网格单元新一千万。
function gridChange() {
var grid = $("#grid").data("kendoGrid");
grid.dataSource.read();
var count = grid.dataSource.total();
$("#countElement").html('Encrypting ' + count + ' Lines');
// get data from the grid
var gridData = $("#grid").data().kendoGrid.dataSource.view();
var grid = $("#grid").data("kendoGrid");
// loop rows
for (i = 0; i < count; i++) {
str = gridData[i].EntityId;
EntityIdhash = CryptoJS.SHA256(str);
// remove old value
// enter new value
console.log('EntityId: ' + gridData[i].EntityId + '\n');
console.log('EntityId encrypted: ' + EntityIdhash + '\n');
}
};
好了,据我所知,您更改网格那么你一定要牛逼o点击“保存”按钮,并让它在您更改的每一行中循环运行并保存这些更改? – Keith
是@Keith,你有这个权利 –
你使用内联编辑还是你必须点击一个按钮来编辑行? – Keith