Easyui 设置datagrid 进入编辑状态,保存结束编辑

2023-05-20,,

在datagrid中如何实现让一行进入编辑状态,修改数据后,保存信息呢?

     //点击列表变成文本框,进入可编辑状态

     $(function () {
var doc = $(document),
table = $("#divReportTable");
doc.on("mousedown", ".btnEdit", function () { var th = $(this),
ind = th.attr("index"),
keyid = th.attr("keyid"); type = th.attr("type");
if (th.hasClass("btnEdit")) {
if (type == "edit") { table.datagrid("beginEdit", ind);
setTimeout(function () {
th.html("保存")
.attr("type", "sava");
var _ele = table.datagrid('getEditors', ind); })
} else if (type == "sava") {
var ele = table.datagrid('getEditors', ind); table.datagrid("endEdit", ind);//结束编辑 @*//执行保存的操作
$.ajax({
url: '@Url.Action("ActionName", "ControllerName")',
data: { "ID": keyid, "Score": Score },
type: "POST",
async: true,
dataType: "json",
success: function (result) {
if (result.Success == true) {
RefreshData()
} else {
//alert('失败');
}
}
});*@
}
}
}) doc.on("mousedown", ".datagrid-editable-input", function () {
//alert('点击了文本框');
console.log(this);
//PersonSelect('11', '11txt'); var user = $(this).val();
$(this).val(user.UserName); }); })
col.push({
title: "操作", field: "Operate", width: 120, align: "center", resizeable: false, formatter: function (value, row, index) {
return "<a href=\"javascript:void(0)\" class='btnEdit' index='" + index + "' keyid='" + row.ID + "' type='edit'>编辑</a>"
}
});
colOne.push({
title: "填报人", field: "FillUser", width: 135, align: "center", resizeable: false, rowspan: rows, formatter: function (value, row) {
return WorkModel.FormateUser(row.FillUser, row.FillUserName, 1, row.ID, fromType);
},
editor: { type: "text" }
});

给列加上editor:{type:"text"} 进入编辑状态后,编辑状态下,这一列将显示成文本框. type:字符串,编辑类型,可选值:text,textarea,checkbox,numberbox,validatebox,datebox,combobox,combotree。

Easyui 设置datagrid 进入编辑状态,保存结束编辑的相关教程结束。

《Easyui 设置datagrid 进入编辑状态,保存结束编辑.doc》

下载本文的Word格式文档,以方便收藏与打印。