Reputation: 22587
I am trying to set the default value of a checkbox when the user hits the inlineNav "Add" button.
It would seem this question would contain the answer I desire
jqGrid add item checkbox field defaulted to checked
but alas, it doesn't work. I am using the following entry in my colModel:
{name:'enabled', index:'`enabled`', width:120,editable:true, edittype:"checkbox", editoptions:{value:"1:0", defaultValue:"1"}, formatter:"checkbox", align:"center"}
I have tried {defaultValue:1}, {value:"Yes:No", defaultValue"Yes"}, {defaultValue:function(){return:"1"}}
etc. but all don't seem to do the trick.
Can someone please help me? Am I missing something obvious, before I go rooting around in the source to help figure it out.
Upvotes: 1
Views: 6411
Reputation: 221997
I suppose that you use not the last version of jqGrid. The problem with the usage of defaultValue
property of editoptions
exist in the version 4.3.0, but it's fixed in the version 4.3.1.
I make minimal modifications in the demo from my answer on your old question. Compare the demo which uses jqGrid 4.3.1 with the same demo which uses old version (4.3.0) of jqGrid. If you click on "Add" button on the new demo the checkbox will be added checked which corresponds the setting
editoptions: {value: 'Yes:No', defaultValue: 'Yes'}
On the other side the demo which uses jqGrid 4.3.0 ignore the setting and create always unchecked checkbox.
Upvotes: 4