喜亞姆使用免費的jqGrid得到所有行更改CRUD中的jqGrid 4.15.1如何與BTN點擊
我想BTN點擊獲取〔實施例都在改變行 3行編輯 2行插入 1行刪除 IAM使用此代碼,我想tish導致插入該行
我插入新的這棵樹行
{ id: "gridad", Name: "Name 4", PackageCode: "83123a", other: "x",> },
{ id: "gridadd", Name: "Name 5", PackageCode: "834", other: "x", > },
{ id: "gridadd", Name: "Name 6", PackageCode: "83566a", other: "z", }
編輯此行
> { id: "10", Name: "Name 122", PackageCode: "83566a1000", other: "z",
> }
中刪除此行
> { id: "20", Name: "Name 3", PackageCode: "83432a", other: "y"},
這是我的代碼
$(function() {
"use strict";
var data = [
{ id: "10", Name: "Name 1", PackageCode: "83123a", other: "x", subobject: { x: "a", y: "b", z: [1, 2, 3]} },
{ id: "20", Name: "Name 3", PackageCode: "83432a", other: "y", subobject: { x: "c", y: "d", z: [4, 5, 6]} },
{ id: "30", Name: "Name 2", PackageCode: "83566a", other: "z", subobject: { x: "e", y: "f", z: [7, 8, 9]} }
],
$grid = $("#packages");
$grid.jqGrid({
data: data,
datatype: "local",
colModel: [
{ name: "PackageCode", width: 110 },
{ name: "Name", width: 300 }
],
pager: "#packagePager",
rowNum: 2,
rowList: [1, 2, 10],
viewrecords: true,
rownumbers: true,
caption: "Packages",
height: "auto",
sortname: "Name",
autoencode: true,
gridview: true,
ignoreCase: true,
});
$grid.jqGrid("navGrid", "#packagePager",
{ add: false, edit: false, del: false }, {}, {}, {},
{ multipleSearch: true, multipleGroup: true });
$grid.jqGrid("filterToolbar", { defaultSearch: "cn", stringResult: true });
});
這個按鈕來獲取所有變化
$("#customerCodesTableSave").click(function() {
var gridData = myGrid.jqGrid('getRowData');
var postData = JSON.stringify(rowdata);
alert(gridData.length);
alert(postData);
for (var i = 0; i < gridData.length; i++) {
alert(i + "_" + (gridData[i]['id']));
if (gridData[i].id == $(myGrid)[0].id + "_0")
{
alert(gridData[i]['id']);
}
//myGrid.jqGrid('saveRow', gridData[i]['id']);
}
saveGrid();
});
首先我修復了在你的問題中使用的標籤。請閱讀這裏的標籤[mvcjqgrid](https://stackoverflow.com/tags/mvcjqgrid/info)和[free-jqgrid](https://stackoverflow.com/tags/free-jqgrid/info)的描述。目前尚不清楚您計劃使用哪種編輯模式。根據選擇的編輯模式,可以使用相應的回調來增加插入,刪除和編輯行的計數器。我根據你的代碼創建了演示https://jsfiddle.net/dnfk8hmr/20/。您可以通過包含您需要的編輯來擴展它。 – Oleg
謝謝更新此演示 – saeed3164
歡迎您!您打算使用哪種編輯模式? – Oleg