free-jqgrid使用edittype编辑列:"复选框",editoptions.value:" 1:0"不起作用

时间:2018-04-25 13:51:48

标签: jquery jqgrid free-jqgrid

free-jqgrid 中,使用 edittype编辑列时:"复选框" editoptions.value =" 1 :0" ,如果之前为0,则无法将字段值设置为1.当您检查字段并提交表单时,该列仍未选中。

这在 jqGrid 中效果很好。

这种奇怪的行为可以在以下JSFiddle example.中看到(从OlegK's example分叉)

在此示例中,如果您编辑并检查以前未选中字段的 inCharge 字段,则在提交表单后,它将保持未选中状态。
另一方面,如果选中它,您可以选中或取消选中它,提交后,它将按预期进行。
此外,当您添加记录时,如果您检查 inCharge 字段,则在提交后仍未选中。

这是代码



$(function() {
  "use strict";
  $("#grid").jqGrid({
      colModel: [{
          name: "id",
          width: 20,
          hidden: true,
          editable: false,
        },
        {
          name: "firstName",
          width: 200,
          editable: true
        },
        {
          name: "lastName",
          width: 200,
          editable: true
        },
        {
          name: "inCharge",
          width: 100,
          editable: true,
          formatter: "checkbox",
          edittype: "checkbox",
          editoptions: {
            value: "1:0"  // doesn't seem to work properly.
          }
        }
      ],
      data: [{
          id: 10,
          firstName: "Angela",
          lastName: "Merkel",
          inCharge: "1"
        },
        {
          id: 20,
          firstName: "Vladimir",
          lastName: "Putin",
          inCharge: "1"

        },
        {
          id: 30,
          firstName: "David",
          lastName: "Cameron",
          inCharge: "1"

        },
        {
          id: 40,
          firstName: "Barack",
          lastName: "Obama",
          inCharge: "0"

        },
        {
          id: 50,
          firstName: "François",
          lastName: "Hollande",
          inCharge: "0"

        }
      ],
      pager: true,
      pgbuttons: false,
      pginput: false,
      viewrecords: true,
      pagerRightWidth: 90
    })
    .jqGrid('navGrid', {
      edittext: 'Edit',
      addtext: 'Add',
      deltext: 'Del',
      search: false,
      view: true,
      viewtext: 'View',
      refresh: true,
      refreshtext: 'Refresh'
    });
});

<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/themes/redmond/jquery-ui.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.15.4/css/ui.jqgrid.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.15.4/jquery.jqgrid.min.js"></script>
<table id="grid"></table>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

您描述的问题是表单编辑中的错误,在the issue #432中有所描述。这个问题已在Git上的代码中修复。演示

https://jsfiddle.net/OlegKi/dvyo36hw/11/

使用原始代码,但

https://rawgit.com/free-jqgrid/jqGrid/master/js/jquery.jqgrid.min.js

而不是

https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.15.4/jquery.jqgrid.min.js

可以验证问题是否已解决。

相关问题