我把這個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