0
votes

i am using checkboxmodel to select rows but i want to make some rows to be selection disabled based on some logic... here is my what i am trying but 'beforeselect' function doesn't even fires

    selModel: Ext.create('Ext.selection.CheckboxModel', {
      checkOnly: true,
    mode:'multi',
   listeners: {
     beforeselect:function(grid){
    var grid=Ext.getCmp('mylist');     
        var selectionModel=grid.getSelectionModel();
    var selectedRecords=selectionModel.getSelection();
    var myValue=selectedRecords[0].get('nowreceive');
    var myvalue1=selectedRecords[0].get('received');
    if(myValue>myvalue1)
    {return false;}
    else 
    return true;
        }}  }
    ),
2

2 Answers

3
votes

beforecellmousedown event in the view config works for me.This is done in the viewconfig of the grid...

 viewConfig: {
 listeners: {
 beforecellmousedown: function(view, cell, cellIdx, record, row, rowIdx, eOpts){
               var myvalue=record.get('quantity_ordered');
               var myvalue1=record.get('quantity_received')
               if(myvalue==myvalue1)
               {
               return false;
               }
                   else {
                   return true;
                   }
            }
        }
    },
0
votes

How do you know the event is not firing? It should be, but my guess is that selectedRecords[0] is not defined and that crashes your execution, because getSelection() probably returns an empty array, before any selection has occurred.

What you should do is to use the second argument of beforeselect, which is the record that's going to be added to the selection.

So you can implement your listener in a much simpler way:

beforeselect: function (selModel, record) {
    if (record.get('nowreceive') > record.get('received')) {
        return false;
    }
}