Question

I have an Enhanced Grid populated by an ItemFileWriteStore. One of the items of data in the store is:

check: true

Then in the enhanced grid I have:

{
   field: "check",
   name: "Value Check",
   editable: true,
   type: dojox.grid.cells.Bool
}

This gives me a column full of checkboxes. I haven't been able to find how to handle checking these checkboxes. I want to start with every checkbox checked, and if you uncheck one it removes a corresponding piece of data. Is there some event handler I can attach with maybe dojo/on? Or some method on enhanced grid that I'm not aware of? I haven't been able to find any documentation on this, I feel like I'm missing something.

Was it helpful?

Solution 2

I found that the best solution was to attach a handler to the "RowClick" event, since every time you click on a checkbox, the RowClick event is fired. Then loop through the data store and update everything based on the checkbox. It's definitely not efficient, but does what I need it to. It's something like this:

grid.on("RowClick", function (event) {
  for (var i=0; i<store._arrayOfAllItems.length; i++) {
    if (grid.getItem(i)) {
      if (grid.getItem(i).check[0]) {
        // row is checked, do something
      } else {
        // row is not checked, do something else
      }
    }
  }
} 

As far as I can tell, event doesn't pass an information useful for identifying which row in the grid was clicked (I'm not 100% sure, there's a lot in it). So this is the best way I came up with.

OTHER TIPS

You would do something like this::

require(['dijit/registry','dojo/on','dijit/WidgetSet','dojo/on'],function(reg,on){
    reg.byClass("dojox.grid.cells.Bool").forEach(function(node){
                   on(node.domNode,'click',function(){alert('hello');});
     });

});
       {
            name: 'Paid',
            field: 'paid',
            width: '40px',
            type: dojox.grid.cells.Bool,
            editable:true,
            doclick:function(e){
                if(e.target.tagName == 'INPUT'){
                    if(confirm("Sure?")){
                        this.applyStaticValue(e.rowIndex);
                    } else {
                        e.target.checked = !e.target.checked;
                    }
                }
            }
        }

This is a old question and I googled here. Wish my answer can help someone.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top