我的每个行都有一个带有添加和删除按钮的kendo网格。每一行都有一个html输入控件。当我向输入控件添加一些值并点击添加按钮值时会被清除。 如何保存每个输入控件值?
<script id="ob-template" type="text/x-kendo-template">
<input id="tree"/>
</script>
<script>
var grid = $("#grid").kendoGrid({
columns: [
{ field: "DispalyName", title: "DispalyName" },
{ field: "Value", title: "Value", template: $("#ob-template").html() },
{
command: [
{ title: "create", template: "<img class='ob-image' src='../DefaultAssets/Images/New.png' style='padding: 0 8px 0 8px;' />" },
{ title: "up", template: "<img class ='up-image' src='../DefaultAssets/Images/UpArrow.png' style='padding: 0 8px 0 8px;' />" },
{ title: "down", template: "<img class ='down-image' src='../DefaultAssets/Images/DownArrow.png' style='padding: 0 8px 0 8px;' />" },
{ title: "delete", template: "<img class ='delete-image' src='../DefaultAssets/Images/Delete.png' style='padding: 0 8px 0 8px;' />" }],
}
]
$("#grid").on("click", ".ob-image", function (e) {
var grid = $("#grid").data("kendoGrid");
grid.addRow();
});
</script>
HTML
<div id="grid" style="float: left;"></div>
答案 0 :(得分:0)
如果要添加行,则需要插入新值。 也许像:
var datasource = grid.dataSource;
var newRecord = { DispalyName: "8164", Value: "147"}
datasource.insert(newRecord);