简体   繁体   English

复选框(dojox.grid.cells.Bool)提交两次

[英]Checkbox (dojox.grid.cells.Bool) Submitting Twice

I have a form with a number of columns, one being a Checkbox which is sending two form submits on-click of the checkbox itself and causing database lockouts. 我有一个包含多个列的表单,其中一个是复选框,它会发送两个表单提交单击复选框本身并导致数据库锁定。

index.jsp: 的index.jsp:

var gridLayout = [
  ...
  {name:"Recurring", field:"isRecurring", type: dojox.grid.cells.Bool, width: "50px",editable:true}
  ...
]

var grid = new dojox.grid.DataGrid({
  id: 'grid',
  store: myStore ,
  structure: gridLayout
});

dojo.connect(grid, 'onApplyCellEdit', function (a,index,c) { submit(index) } );

Is there an alternative to the 'onApplyCellEdit'? 是否有'onApplyCellEdit'的替代品?

Today I got the same problem. 今天我遇到了同样的问题。

Official response of dojo: 道场的官方回应:

DojoX Grid and EnhancedGrid are deprecated in favor of ​dgrid and ​gridx. 不推荐使用DojoX Grid和EnhancedGrid,而选择dgrid和gridx。 You should upgrade your code to use one of those two grids. 您应该升级代码以使用这两个网格中的一个。 We will consider patches to the old DojoX Grid code though. 我们将考虑旧的DojoX Grid代码的补丁。

See THIS for a workaround. 请参阅此处了解解决方法。 I did'nt tried it yet. 我还没试过呢。

What user1189762 said is true, but i think there is another way around it. user1189762说的是真的,但我认为还有另一种方法。

You can use the formater in your layout 您可以在布局中使用formater

      var layout = [[
                        { 'name': 'Column 1', 'field': 'id', hidden: true },
                        { 'name': 'Name', 'field': 'name', 'width': '200px' },
//This is the formatter for the Checkboix attribute so it can be in the middle in the start or wherever you need it
                        { 'name': 'Delete Mapping', 'field': '_item', 'width': '175px', formatter: checkBoxFormatter },
                        { 'name': 'Note', 'field': 'note', hidden: true },
                        { 'name': 'mappings', 'field': 'mappingelements', hidden: true }
                    ]];






 function checkBoxFormatter(value, rowIndex)
    {
    var checkBox = new CheckBox({            
                checked: false,
                onChange: function(b){ 
//The value is whatever you want the two parameter value and rowindex will get the row value or the row index
                  submit(value)
                             }
            });
    } 

This Should work. 这应该工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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