admin管理员组

文章数量:1023764

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.

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.

Share Improve this question edited May 23, 2017 at 12:27 CommunityBot 11 silver badge asked Feb 22, 2012 at 17:25 adamadam 22.6k21 gold badges91 silver badges120 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

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.

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.

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.

Share Improve this question edited May 23, 2017 at 12:27 CommunityBot 11 silver badge asked Feb 22, 2012 at 17:25 adamadam 22.6k21 gold badges91 silver badges120 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

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.

本文标签: javascriptjqgrid checkboxSet default value on add newStack Overflow