【问题标题】:jqgrid submitted wrong value for checkboxjqgrid为复选框提交了错误的值
【发布时间】:2011-05-18 10:38:06
【问题描述】:

我发现了类似的问题 (when checkbox is checked, wrong value is submitted for the property),但它并没有解决我的问题。

我使用 jgrid 进行数据呈现和编辑。如果我只使用文本字段,一切都会很好,但是当我开始使用复选框时它会失败。我真的很简单地使用默认值编写代码:

colModel:[  {name:'robotsi',index:'robotsi', width:90, align:"right",sortable:false,editable:true,edittype:'checkbox'}  ]

在 HTML 中它看起来很漂亮:

<input id="robotsi" class="FormElement" type="checkbox" value="on" offval="off" name="robotsi" role="checkbox">

但是当我点击“提交”时,我得到了:

[robotsi] => off

即使我检查它...当我添加时:

editoptions: { value:"Yes:No" }

它的工作原理相同,我得到的唯一值是 0。我根本没有 JavaScript 错误。

请帮我看看我犯了什么错误。

【问题讨论】:

  • 你有什么版本的jQuery?
  • 我有最新的 jQuery。我只是使用选择而不是复选框来解决它。

标签: jqgrid checkbox


【解决方案1】:

不是很优雅,但我通过添加以下代码解决了这个问题:

onInitializeForm: function(formId) {
    $(".FormGrid input[type='checkbox']").bind("load click", function() {
        $(this).attr("value", $(this).is(":checked"));
    });
},

【讨论】:

    【解决方案2】:

    试试下面的

    colModel:[  {name:'robotsi',index:'robotsi', width:90, align:"right",sortable:false,editable:true,edittype:'checkbox' formatter:'checkbox'}  ]
    

    【讨论】:

      猜你喜欢
      • 2011-08-09
      • 1970-01-01
      • 2013-09-22
      • 2021-04-02
      • 2014-06-26
      • 2017-02-04
      • 2014-08-27
      • 2012-11-11
      • 1970-01-01
      相关资源
      最近更新 更多