I have a free JqGrid setup in such a way such that onclick of the row, editgridrow is called and the form loads. Now when the user changes the value of a certain field on the form, I want to be able to show/hide other fields depending upon what was defined in the editable parameter of the colModel.
I have defined the dataEvents in the cmTemplate part of the grid, so that any change any where on the form will trigger the event. I have also gotten to the colModel. What I am unsure of is how to apply the rule inside of the ColModel to that particular row being edited.
cmTemplate: {
align: "center",
autoResizable: true,
editrules: {edithidden: true},
editoptions:{
dataEvents: [
{
type: 'change',
fn: function(e) {
var form = $(e.target).closest('form.FormGrid');
handleEvent(e.target.id,e.target.value,form[0],$(newTable).jqGrid())
}
}
]
}
},
function handleEvent(eventSource,eventSourceValue,form,grid)
{
var targets = eventSources[eventSource];
if(targets != null)
{
var colModel = grid.getGridParam("colModel");
for(var i=0; i<targets.length;i++)
{
for(var z=0; z<colModel.length;z++)
{
if(colModel[z]["name"] == targets[i])
{
if(colModel[z]["edittype"] == "select")
{
var dropdownName = "drp"+targets[i].replace("-","_");
var newOptions = buildOptions(eval(dropdownName),eventSourceValue);
$("select#"+targets[i]+".FormElement", form).html(newOptions)
}
break;
}
}
}
}
}
I have already handled other dropdown changes in the handle event BUT I also need to be able to handle all other changes to the form , for example showing fields etc but I do not want to write duplicate code again and want to access the editOptions of the colModel and trigger the change to the form