I’m using jqgrid, and there are too many options there.
What I want to do is setup a predefined options, and use it later.
//my predefined options
var edit_options = {
editrules:
{
required:true
,edithidden:true
,editable:true
}
And then when executing
jGrid.jqGrid({
...
colNames:['id','Code', 'Name'],
colModel:[
//id
{name:'sample_id'
,index:'sample_id'
},
//Code
{name:'sample_code'
,index:'sample_code'
,edit_options
},
//Name
{name:'sample_name'
,index:'sample_name'
,edit_options
}
Of course ‘edit_options’ here give error. How to do that correctly ?
I just want the second and third options to use the predefined options.
I’m looking at $.extend(), but can’t figure it out correctly.
You can use jQuery’s
extend-method:This method takes an arbitrary number of objects, and copies the properties of each object in turn into the first object. Note that if the same key exists multiple times, then the current value will be overwritten with the new one.