i starter in jqgrid. i have one jqgrid and button in page . i want user edit rows example row1, row2,row3,... , and click in button, when click in button send data rows1,2,3 to server. but jqGrid when user editing row send data to server. please give me solution for my problem. thanks all
i write this code
var mydata = [
{ id: "1", REQUEST_ID: "2007-10-01", WAYBILL_NO: "test", COST_ID: "note", COST_NAME: "200.00", COST_AMOUNT: "10.00", Subcategory: "1" },
{ id: "2", REQUEST_ID: "2007-10-02", WAYBILL_NO: "test2", COST_ID: "note2", COST_NAME: "300.00", COST_AMOUNT: "20.00", Subcategory: "2" },
{ id: "3", REQUEST_ID: "2007-09-01", WAYBILL_NO: "test3", COST_ID: "note3", COST_NAME: "400.00", COST_AMOUNT: "30.00", Subcategory: "1" },
{ id: "12", REQUEST_ID: "2007-09-10", WAYBILL_NO: "test11", COST_ID: "note12", COST_NAME: "500.00", COST_AMOUNT: "30.00", Subcategory: "1" }
];
var localstr = "0:Select Ones;";
localstr += "1:Dollar";
localstr += ";2:Pond";
localstr += ";3:Youro";
localstr += ";4:Derham";
var lastSel;
var grid = jQuery("#list");
grid.jqGrid({
datatype: "local",
data: mydata,
ajaxGridOptions: { cache: false },
loadonce: true,
direction: "rtl",
height: 'auto',
colNames: ['RequestID', 'WayBillNo', 'CostId', 'CostName', 'Amount', 'CurrencyUnit '],
colModel: [
{ name: 'REQUEST_ID', width: 100, sortable: true, hidden: true },
{ name: 'WAYBILL_NO', width: 100, sortable: true, hidden: true },
{ name: 'COST_ID', index: 'COST_ID', width: 200, sortable: true, hidden: true },
{ name: 'COST_NAME', width: 200, sortable: true },
{ name: 'COST_AMOUNT', width: 100, sortable: true, editable: true },
{ name: 'Subcategory', index: 'Subcategory', width: 200, formatter: 'select', editable: true, edittype: 'select', editoptions: { value: localstr} }
],
sortname: 'Name',
viewrecords: true,
rownumbers: true,
sortorder: "desc",
editurl: 'clientArray',
onSelectRow: function (id) {
if (id && id !== lastSel) {
grid.saveRow(lastSel, true, 'clientArray');
grid.jqGrid('restoreRow', lastSel);
grid.jqGrid('editRow', id, true, null, null, 'clientArray');
lastSel = id;
}
},
pager: '#pager',
caption: ""
}).jqGrid('navGrid', '#pager', { edit: true, add: true, del: false, search: false, refresh: false });
but what is clientArray, and how can use data ino clientArray and send to server?? thanks for help me.
you can store all data change into grid after that create button for user click in this button all data send to server
you change code to this
onSelectRow: function (id) {
if (id && id !== lastSel) {
grid.jqGrid('restoreRow', lastSel);
grid.saveRow(lastSel,true,'clientArray');
grid.jqGrid('restoreRow',lastSel);
grid.jqGrid('editRow', id, true, null, null, 'clientArray');
}
},
and for read data from grid
$("#btnSave").click(function(){
var row=$("#list").jqGrid('getRowData',1);
alert(row.cost_id)
});