Reputation: 175
In my jqGrid, the onSelect function I set dataEvent on a particular column if the column cell is not an empty string.
As long as I edit a row where the particular cell has a value the dataEvent does not get set on the column. This is desired behavior.
Again if I edit a row where the cell is blank and the dataEvent is bound to the column. Again this is desired behavior.
However, once the second senerio is performed the dataevent seems locked to the column even when the check cell has a value.
My onSelect code:
function oSelect(id){
var vjobno = "";
vjobno = $("#timesheetlineitemsqueue").getRowData(id)['jobno'];
$("#timesheetlineitemsqueue").setColProp('date', { editoptions: { dataUrl: '/TimeSheetWebApp/TimeSheetControllerServlet?lifecycle=weekdayoptions'}});
$("#timesheetlineitemsqueue").setColProp('deptno', { editoptions: { dataUrl: '/TimeSheetWebApp/TimeSheetControllerServlet?lifecycle=departmentoptions'}});
$("#timesheetlineitemsqueue").setColProp('iphase', { editoptions: { dataUrl: '/TimeSheetWebApp/TimeSheetControllerServlet?lifecycle=phaseoptions'}});
$("#timesheetlineitemsqueue").setColProp('icategory', { editoptions: { dataUrl: '/TimeSheetWebApp/TimeSheetControllerServlet?lifecycle=categoryoptions'}});
if(vjobno == ""){
$("#timesheetlineitemsqueue").setColProp('jobno', { editoptions: {dataEvents: [{ type: 'click', fn: function(e) {resetvalidation(this.name); }},{ type: 'focus', fn: function(e) {resetvalidation(this.name); }},{ type: 'change', fn: function(e) {validatejobnumber(this.value); }},]}});
}
};
Upvotes: 0
Views: 821
Reputation: 221997
It's important to understand that getGridParam
returns the reference to internal parameters used by jqGrid. Thus you can use for example
var p = $("#timesheetlineitemsqueue").jqGrid("getGridParam");
and access to colModel
using p.colModel
. Alternatively you can use
var colModel = $("#timesheetlineitemsqueue").jqGrid("getGridParam", "colModel");
to get the reference to colModel
array.
To get the column item, which have the name jobno
, one can use iColByName
in free jqGrid. Then
var cm = p.colModel[p.iColByName.jobno];
If you use some old version of jqGrid instead of free jqGRid then you can find the index of jobno
in the loop (see the code of getColumnIndexByName
in the answer for example).
Now you can set any property of cm
item without usage setColProp
. In the same way you can use delete
to delete the property. For example
delete cm.editoptions.dataEvents;
Upvotes: 1