Checkbox (dojox.grid.cells.Bool) Submitting Twice

910 views Asked by At

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:

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'?

2

There are 2 answers

0
Robin Wieruch On

Today I got the same problem.

Official response of dojo:

DojoX Grid and EnhancedGrid are deprecated in favor of ​dgrid and ​gridx. You should upgrade your code to use one of those two grids. We will consider patches to the old DojoX Grid code though.

See THIS for a workaround. I did'nt tried it yet.

0
dori naji On

What user1189762 said is true, but i think there is another way around it.

You can use the formater in your layout

      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.