jQuery jqGrid编辑表单支持多选的字段吗?

我仍然试图找出我是否可以在jqGrid中有一个单元格,当我拉出该行的编辑表单时,我需要一个可以将该列显示为多选列表的GUI。

这可能是:

  1. 复选框列表
  2. 选中列表并选中复选框,以便您可以选择多个。

这在jqGrid中是否可行?

jqGrid支持多选编辑。 它不使用ceckbox进行选择,而是多选select元素。 我在双击时使用内联编辑制作了演示 。 在此处输入图像描述

这是相应的代码:

jQuery(document).ready(function() { var lastSel, mydata = [ {id:0, Name:"Lukas Podolski", Category:"1", Subcategory:"1"}, {id:1, Name:"Michael Schumacher", Category:"1", Subcategory:"2"}, {id:2, Name:"Albert Einstein", Category:"2", Subcategory:"3,4"}, {id:3, Name:"Blaise Pascal", Category:"2", Subcategory:"4"} ], grid = jQuery("#list"); grid.jqGrid({ data: mydata, datatype: 'local', colModel: [ { name: 'Name', index: 'Name', width: 130, editable: true }, { name: 'Category', index: 'Category', width: 100, formatter:'select', editable: true, edittype:'select', editoptions: { value: '1:sport;2:science', multiple: true, size: 2 } }, { name: 'Subcategory', index: 'Subcategory', width: 250, formatter:'select', editable:true, edittype:'select', editoptions: { value: '1:football;2:formula 1;3:physics;4:mathematics', multiple: true, size: 4 } } ], sortname: 'Name', viewrecords: true, rownumbers: true, sortorder: 'desc', pager: '#pager', height: '100%', editurl: 'clientArray', ondblClickRow: function(rowid) { jQuery(this).jqGrid('editRow', rowid, true, null, null, 'clientArray'); }, onSelectRow: function(id){ if (id && id!==lastSel){ jQuery(this).restoreRow(lastSel); lastSel=id; } }, caption: 'Selects with multiselect' }); }); 

顺便说一下,在创建演示期间,我发现,不能使用具有“0”的选择元素作为id,而不是完全支持。 例如,’1:运动; 2:科学’有效,但不是’0:运动; 1:科学’。 如果没有保存“运动”项目的选择。

如果您需要使用带有复选框的更舒适的控制,则必须实现自定义编辑的行为。