简体   繁体   中英

Using XML to set the checkbox in jqgrid

I have a grid that is being loaded with XML data. One of the parameters of the XML is a true/false value and I would like to use that value to select the rows that are pre-selected (multiselect:true).

As an example:

<rows>
<row><data>338</data><host>foo</host><sent>true</sent></row>
<row><data>485</data><host>bar</host><sent>false</sent></row>
</rows>

The checkbox column that I'm referring to is the built-in column that is added as the first column when multiselect is true. The only reason I haven't dumped it and used a custom checkbox column is that there are a bunch of other routines that act on that column so I would like to keep it if possible.

jqGrid column setup:

{ name: 'checked', index: 'checked', 
 editable:true, edittype:'checkbox', editoptions: { value:"True:False"}, 
 formatter: "checkbox", formatoptions: {disabled : false}}

Example local data:

var data = [
    {id:"66", thingy:"Lemiux", blank:"", number:"66", status:"Retired", checked:"Yes"},
    {id:"99", thingy:"Gretzky", blank:"", number:"66", status:"Retired", checked:"No"}
];

Working example on jsfiddle: http://jsfiddle.net/dumbguy5689/9ueDL/

Edit: To deal with the multiselect use the code on this link and then just test the value you pass in the row that contains weather the row should be selected or not. jqGrid Set Selected Rows

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM