Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Checkbox in jqGrid

Tags:

jqgrid

I am trying to create the checkbox inside the jqgrid columns and using the below code

{ 
   name: 'CanDo', width: 50, index: 'CanDo', 
   edittype: 'checkbox', editoptions: { value: "True:False" }, 
   formatter: "checkbox", formatoptions: { disabled: true} 
}

Json object is returning either "True" or "False"

But the check box itself is not created in grid. What would be the issue?

Please help.

Edit: Using jquery.jqGrid.BasicOnly.min.js 4.1.2

$("#pGrid").jqGrid({
            datastr: '@Html.Raw(@Model.PList)',
            datatype: 'jsonstring',
            colNames: ['id','CanDo' ,'Name'],
                colModel: [
                        { name: 'id', hidden: true },
                        { name: 'CanDo', width: 50, index: 'CanDo',editable: true,  edittype: 'checkbox', editoptions: { value: "True:False" }, formatter: "checkbox", formatoptions: { disabled: true},
                        { name: 'Name', width: 150 }                        
                      ],
            pager: '#pager',
            rowNum: 100,
            height: "200",
            viewrecords: true,
            caption: '<span class="spanH2">Test Process</span>'
        });

JSON

{"total":1,"page":1,"records":2,
 "rows": [
   {"id":"1","cell":["1","True","Callback"]},
   {"id":"8","cell":["8","False","Complaint"]}]}
like image 946
Gansun Avatar asked Oct 16 '12 12:10

Gansun


1 Answers

I believe you are missing the editable:true option. Try this:

{ 
 name: 'CanDo', width: 50, index: 'CanDo', 
 editable: true,
 edittype: 'checkbox', editoptions: { value: "True:False" }, 
 formatter: "checkbox", formatoptions: { disabled: true} 
}
like image 93
Justin Ethier Avatar answered Oct 19 '22 23:10

Justin Ethier