【发布时间】:2017-10-26 04:19:12
【问题描述】:
我有这个剑道 ui 网格绑定到一个表。此网格具有激活的批量编辑功能。这意味着我可以直接在网格单元格上更改值并保存它。
我想要完成的是通过每行运行一个循环来更改客户端某些列中显示的值,然后点击保存按钮。
这是我的网格中的内容:
@(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');
}
};
【问题讨论】:
-
好的,据我了解,您对网格进行了更改。然后你想点击“保存”按钮,让它循环遍历你更改的每一行并保存这些更改?
-
是的@Keith,你说得对
-
您使用内联编辑还是必须单击按钮来编辑行?
-
首先,从我们所看到的情况来看,您似乎没有调用
gridChange函数。除非您在document.ready中初始化此事件或其他什么? -
@Sandman,我有新的编辑值。我只想一口气完成。此功能将由一个按钮触发并执行按钮更改。
标签: javascript jquery kendo-ui kendo-grid datasource