Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jqGrid如何向列添加多个复选框_Javascript_Jquery_Checkbox_Jqgrid - Fatal编程技术网

Javascript jqGrid如何向列添加多个复选框

Javascript jqGrid如何向列添加多个复选框,javascript,jquery,checkbox,jqgrid,Javascript,Jquery,Checkbox,Jqgrid,我想在编辑/添加模式下向列添加多个复选框。现在,此列有一个启用了多个选项的选择框。我想用复选框列表或单选按钮列表替换它 我的想法是:用户应该能够通过选中特定单元格中列出的复选框(在添加或编辑模式下:内联)来选择所需的相关选项。保存行后,应仅显示用户选择的选定选项(不带复选框) 下面是我为特定列选择框编写的代码片段: { name: 'RoomTypes', index: 'RoomTypes', width: 300, editable: true, edittype: 'select

我想在编辑/添加模式下向列添加多个复选框。现在,此列有一个启用了多个选项的选择框。我想用复选框列表或单选按钮列表替换它

我的想法是:用户应该能够通过选中特定单元格中列出的复选框(在添加或编辑模式下:内联)来选择所需的相关选项。保存行后,应仅显示用户选择的选定选项(不带复选框)

下面是我为特定列选择框编写的代码片段:

{
     name: 'RoomTypes', index: 'RoomTypes', width: 300, editable: true, edittype: 'select',
                   editoptions: {
                         value: roomTypesFormatterEdit,
                         custom_element: function (value, options) {
                             return $.jgrid.createEl.call(this, "select",
                                 $.extend(true, {}, options, { custom_element: null, custom_value: null }),
                                 value);
                         },
                         custom_value: function ($elem, operation, value) {
                             if (operation === "get") {
                                 return $elem.val();
                             }
                         },
                         multiple: true
                     },
                     align: 'left', formatter: roomTypesFormatter
                 },
其中“RoomTypesFormateEdit”返回将显示在选择框中的酒店房间名称列表

此外,我还想重新安排编辑(编辑模式)行的高度,以适应复选框的高度,或显示选择框中的所有项目

请帮忙
谢谢大家

我认为您不需要编写自定义编辑控件(
custom\u元素
custom\u值
)或自定义格式化程序(
formatter
unformat
)。相反,您只需将
multiple:true
属性添加到
editoptions
,即可拥有基本的multiselect功能。要提高可见性,可以使用一些现有控件,如或。并提供使用jQuery UI MultiSelect小部件的演示。并提供使用Select2的演示。演示没有使用Select2的多选功能,但它只是控件的一个选项(请参阅)。

@gamini2006:欢迎您!我很高兴能帮助你。