使用最新版本的免费jqgrid。 我正在使用以下代码为我的jqgrid。 我有一些问题和疑问:
1)当我转到下一页和上一页时,不确定会发生什么,但我的网格项目不断上下移动。
2)当我为表单字段添加/编辑项目时,我希望网格刷新并从服务器更新,但这不会发生,而且我的新添加的数据会在我的point1中提到的网格中丢失。我尝试添加navOptions:{reloadGridOptions:{fromServer:true}}但仍然没有。
3)当用户点击我的寻呼机上的编辑按钮时,它会打开用户表单字段。我希望提交按钮显示编辑而不是"添加"它目前显示。 以下是我的代码:
<script type="text/javascript">
$(function () {
"use strict";
var $grid = $("#list");
$grid.jqGrid({
url: '@Url.Action("GetData", "Home")',
datatype: "json",
mtype: 'Get',
colNames: ['Id', 'Name', 'Sex', 'Address'],
loadonce: true,
height: '100%',
autowidth: true,
emptyrecords: "No Users found.",
colModel: [
{ name: 'empid', index: 'empid', editable: true, editrules: { required: true}},
{ name: 'fname', index: 'fname', editable: true, editrules: { required: true}}, //currently these are texbox, but I want this to be label which gets filled based on the empid
{ name: 'lname', index: 'lname', editable: true, editrules: { required: true}},
{ name: 'address', index: 'address', editable: true, editrules: { required: true}}
],
cmTemplate: { autoResizable: true, editable: true },
autoResizing: { compact: true, resetWidthOrg: true },
iconSet: "fontAwesome",
guiStyle: "bootstrap",
rowNum: 10,
rowList: [5, 10, 20, "10000:All"],
viewrecords: true,
autoencode: true,
sortable: true,
pager: true,
rownumbers: true,
sortname: "empid",
sortorder: "desc",
pagerRightWidth: 150,
inlineEditing: {
keys: true
},
searching: {
loadFilterDefaults: false,
closeOnEscape: true,
searchOperators: true,
searchOnEnter: true,
caption: "Search",
Find: "Search"
},
editurl:'@Url.Action("GetDetails", "Home")',
formEditing: {
reloadGridOptions: { fromServer: true },
reloadAfterSubmit: true,
width: 460,
closeOnEscape: true,
closeAfterEdit: true,
closeAfterAdd: true,
closeAfterDelete: true,
savekey: [true, 13],
addCaption: "Add",
editCaption: "Edit",
bSubmit: "Add"
},
formDeleting: {
width: 320,
caption: 'Delete'
},
navOptions: { reloadGridOptions: { fromServer: true } }
}).jqGrid("navGrid")
.editGridRow("new", properties);
});
</script>
答案 0 :(得分:0)
上面的前两项我可以使用以下代码解决:
navOptions: { reloadGridOptions: { fromServer: true } }
但是当我点击编辑工具栏按钮时,我无法解决我无法更改添加按钮的文本以将其更改为编辑的第3项