I try to inline update a specify cell's row of jQgrid.
i send the parameter using ajax.
i could get for id value, but i have difficulty to get cell value from a column named Status
. My code below seems not working.
{name:'Status', index:'Status', width:50,search:true,align : 'center',
editable: true,edittype:"checkbox",editoptions: {value:"OK:"},
stype:'text',searchoption:{sopt:['cn']}}
loadComplete: function () {
var iCol = getColumnIndexByName($(this),'Status'),rows = this.rows,i,c = rows.length;
for (i = 1; i < c; i += 1) {
$(rows[i].cells[iCol]).click(function (e) {
var id = $(e.target).closest('tr')[0].id,isChecked = $(e.target).is(':checked');
var rowData = jQuery("#list").getRowData(id);
var colData = rowData['Status'];
$.ajax({
type : "POST",
url : "process1.php",
async : false,
cache : false,
data : "id="+id+"&Status="+colData+"&action=cekmark",
success: function() {
$("#list").trigger("reloadGrid");
return this;
}
});
return false;
});
}
}
this is ajax result:
id:50831
Status:
action:cekmark
try to use the answer below
var rowData = jQuery("#list").getRowData(id);
var colData = rowData.Status;
found after click at selected cell (checkbox not yet show) but ajax directly send the parameter to server.why?
ANSWER
Based on oleg answer i change some script which suitable with my case :
onCellSelect: function () {
var iCol = getColumnIndexByName($(this),'Status'),rows = this.rows,i,c = rows.length;
for (i = 1; i < c; i += 1) {
$(rows[i].cells[iCol]).click(function (e) {
var id = $(e.target).closest('tr')[0].id,isChecked = $(e.target).is(':checked');
var isChecked = isChecked? "OK" : "";
$.ajax({
type : "POST",
url : "process1.php",
async : false,
cache : false,
data : "id="+id+"&Status="+isChecked+"&action=cekmark",
success: function() {
$("#list").setGridParam({datatype:'json', page:1}).trigger('reloadGrid'); //this make your grid reloaded without reload page
//$("#list").trigger("reloadGrid");
return this;
}
});
return false;
});
}
}