Create Checkbox in jqGrid
Asked Answered
S

1

7

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"]}]}
Saharanpur answered 16/10, 2012 at 12:58 Comment(1)
Did you try setting as editoptions: { value: "true:false" }?Bordereau
S
12

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} 
}
Saragossa answered 16/10, 2012 at 13:43 Comment(8)
Now I added that option as well. Still the issue is not resolved.Saharanpur
Hmm... not sure what to tell you. I think you need to post a larger example with your full jqGrid code, the XML/JSON response from the server, and a description/picture of what actually is displaying in your grid.Saragossa
I just verified the html created for that specific grid cells. It has <td title="False" role="gridcell" aria-describedby="pGrid_CanDo">Saharanpur
What does the grid cell contain?Saragossa
I am using "jquery.jqGrid.BasicOnly.min.js". Does this has any limitations?Saharanpur
I do not see the closing </ td>.Lutes
@Gansun: Should be something like: <td role="gridcell" title="" aria-describedby="pGrid_CanDo"><input type="checkbox" value="&nbsp;" offval="no"></td>Lutes
@Saharanpur - Most likely. You need to include the code for editing. I suggest downloading the entire jqGrid 4.1.2 code to see if it fixes your problem. If it does, then you can selectively remove components you do not need.Saragossa

© 2022 - 2024 — McMap. All rights reserved.