Jqgrid:网格刷新编辑,分页
Jqgrid: Grid refresh on edit, paging
使用最新版本的免费 jqgrid。
我正在为我的 jqgrid 使用下面的代码。
我有一些问题和疑问:
1) 当我转到下一页和上一页时,不确定会发生什么,但我的网格项目一直上下移动。
2) 当我 add/edit 表单字段的项目时,我希望网格刷新并从服务器获取更新,但这并没有发生,我新添加的数据再次在网格中丢失,如中所述我的观点1。我尝试添加 navOptions: { reloadGridOptions: { fromServer: true } } 但仍然没有。
3) 当用户单击我的寻呼机上的编辑按钮时,它会打开用户表单字段。我希望提交按钮显示编辑而不是当前显示的 "Add"。
下面是我的代码:
<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>
上面的前两项我可以使用下面的代码解决:
navOptions: { reloadGridOptions: { fromServer: true } }
但是我仍然无法解决第 3 项,我无法更改添加按钮的文本以在单击编辑工具栏按钮时将其更改为编辑
使用最新版本的免费 jqgrid。 我正在为我的 jqgrid 使用下面的代码。 我有一些问题和疑问:
1) 当我转到下一页和上一页时,不确定会发生什么,但我的网格项目一直上下移动。
2) 当我 add/edit 表单字段的项目时,我希望网格刷新并从服务器获取更新,但这并没有发生,我新添加的数据再次在网格中丢失,如中所述我的观点1。我尝试添加 navOptions: { reloadGridOptions: { fromServer: true } } 但仍然没有。
3) 当用户单击我的寻呼机上的编辑按钮时,它会打开用户表单字段。我希望提交按钮显示编辑而不是当前显示的 "Add"。 下面是我的代码:
<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>
上面的前两项我可以使用下面的代码解决:
navOptions: { reloadGridOptions: { fromServer: true } }
但是我仍然无法解决第 3 项,我无法更改添加按钮的文本以在单击编辑工具栏按钮时将其更改为编辑