xueru
xueru

Reputation: 765

when checkbox is checked, wrong value is submitted for the property

In the jqgrid, the column is defined as following:

  {name:'production', index:'production', width:60, align:'center', formatter:'checkbox',editable:true,edittype:'checkbox',editoptions:{value:"true:false"},formoptions:{ rowpos:10,elmprefix:" " }},

Generated html for the edit form is the following:

<input type="checkbox" value="true:false" offval="false" id="production" role="checkbox" class="FormElement">

So when the checkbox is unchecked, the correct value 'false' is submitted, but when the checkbox is checked, 'true:false' is submitted, which is obviously wrong. I would want 'true' to be submitted. What am I doing wrong?

Thanks!

Upvotes: 2

Views: 4514

Answers (2)

Nalan
Nalan

Reputation: 11

Make sure the values should be True/False not Yes/No. add this attribute in the column:

editoptions: { value: "True:False" }

Upvotes: 1

firegnom
firegnom

Reputation: 833

try removing editoptions like that :

{name:'production', index:'production', width:60, align:'center', formatter:'checkbox',editable:true,edittype:'checkbox',formoptions:{ rowpos:10,elmprefix:"&nbsp;" }},

from jqgrid wiki :

If in editoptions, the value property is not set, jqGrid searches for the following values (false|0|no|off|undefined) in order to construct the checkbox.

so it should work for true:false out of the box .

Make also sure that in your data you have production as true or false value

Upvotes: 2

Related Questions