Hello everyone..!!!
I upgraded my jQgrid from version 4.8.2 to 4.9.2. Due to this I am facing problem to get selected value of dropdown column in custom func
.
The scenario is, when I go to save record during Add/Edit operation, as per jQgrid work flow, the execution pointer first comes in custom_func: function (value, colName){}
. The function parameter value
should contain selected value of dropdown, but its gives me selected text.
I google this problem, but I didn't found any relevant solution. I hope someone here have faced same problem and might have found any possible solution.
Here is my jQgrid code,
var oGrid = $('#tbPOFields'), topPagerSelector = '#' + $.jgrid.jqID(oGrid[0].id) + "_toppager", lastSel;
oGrid.jqGrid({
url: sRelativePath + '/WSAjax.asmx/GetDataForGridInEdit',
mtype: "POST",
datatype: "json",
ajaxGridOptions: { contentType: "application/json; charset=utf-8" },
serializeGridData: function (data) {
return JSON.stringify(data);
},
jsonReader: {
root: "d.rows",
page: "d.page",
total: "d.total",
records: "d.records"
},
colNames: ['ConsigneeId', 'Consignee'],
colModel: [
{ name: 'ConsigneeId', index: 'ConsigneeId', hidden: true },
{ name: 'Consignee', index: 'Consignee', sortable: false, title: false, width: 42, editable: true, edittype: "select",
editrules: {
required: true,
custom: true,
custom_func: function (value, colName) {
if ($('#tbItems_Consignee').length === 1) {
var selrow = $('#tbItems').jqGrid('getGridParam', 'selrow');
$('#tbItems').jqGrid('setCell', selrow, 'ConsigneeId', value);
}
if (g_bEditMode && value === g_sValueNONE && !g_bIsOrderType_Maintenance)
return [false, " is an invalid Consignee.<br/>Please select a valid Consignee before saving."];
else {
return [true, ""];
}
}
},
editoptions:
{
value: eval('(' + g_oConsigneeList + ')'),
dataEvents: [
{ type: 'keyup', fn: function (e) { $(e.target).trigger('change'); } },
{
type: 'change',
fn: function (e) {
if (!e.isTrigger) {
var selrow = $('#tbItems').jqGrid('getGridParam', 'selrow');
var ConsigneeId = $(this).val();
$('#tbItems').jqGrid('setCell', selrow, 'ConsigneeId', ConsigneeId);
}
}
}]
}
}
],
prmNames: { page: "pageIndex", rows: "pageSize", sort: "sortIndex", order: "sortDirection" },
autowidth: true,
postData: {
filters: null,
spName: 'GetPOFieldsDetailsList',
paramXML: ''
},
width: 'auto',
height: 'auto',
rowNum: 1000,
rowList: [1000],
sortname: "",
sortorder: "asc",
page: 1,
gridview: true,
toppager: true,
autoencode: true,
ignoreCase: true,
viewrecords: true,
caption: 'Fields',
editurl: 'clientArray',
emptyrecords: "No records to view.",
footerrow: true,
onSelectRow: function (rowid) {
if (rowid && rowid != lastSel) {
if (typeof lastSel !== "undefined") {
$(this).jqGrid('restoreRow', lastSel);
}
lastSel = rowid;
}
}
});
oGrid.jqGrid('navGrid', topPagerSelector, { add: false, edit: false, search: false, refresh: false }, {}, {}, {});
oGrid.jqGrid('inlineNav', topPagerSelector, {
addParams: {
addRowParams: {
oneditfunc: function (rowid) {
updateJqGridButtonState($(this), jqGridMode.Add);
},
aftersavefunc: function (rowid, response) {
g_bIsDataChanged = true;
SavePOFieldsDetails($(this), rowid);
updateJqGridButtonState($(this), jqGridMode.None);
},
afterrestorefunc: function () {
updateJqGridButtonState($(this), jqGridMode.None);
}
}
},
editParams: myFieldsEditParams
});