1. #1
    Sencha User
    Join Date
    Aug 2008
    Location
    Gothenburg
    Posts
    157
    Vote Rating
    2
    Dr. Flink is on a distinguished road

      0  

    Default CheckBoxSelectionModel: Clicking cell selects row

    CheckBoxSelectionModel: Clicking cell selects row


    I'm using the CheckBoxSelectionModel in a EditorGridPanel. I don't want the checkbox/row to be selected when the user clicks a cell (if it's not the checkbox though...).
    I've been looking in the API, but using beforerowselect wont work. I need to figure out how to see which column was clicked.

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    This is normal behaviour, as long as you only use the CheckboxSelectionModel as column and not as selectionmodel.

  3. #3
    Sencha User
    Join Date
    Aug 2008
    Location
    Gothenburg
    Posts
    157
    Vote Rating
    2
    Dr. Flink is on a distinguished road

      0  

    Default


    Quote Originally Posted by Condor View Post
    This is normal behaviour, as long as you only use the CheckboxSelectionModel as column and not as selectionmodel.
    But, am I not using CheckboxSelectionModel as a column?
    Code:
    gridSm = new Ext.grid.CheckboxSelectionModel({
        listeners: {
            selectionchange: function() {
                if(gridSm.getCount() > 0) {
                    Ext.getCmp('gridBtnDelete').enable();
                    Ext.getCmp('gridBtnPrint').enable();
                }
                else {
                    Ext.getCmp('gridBtnDelete').disable();
                    Ext.getCmp('gridBtnPrint').disable();
                }
            }
        }
    });
    
    gridCm = new Ext.grid.ColumnModel([
        gridSm,
        {
            header: "Fastighet",
            dataIndex: "street",
            editor: new Ext.form.TextField({
                allowBlank: false
            })
        },
        {
            header: "Kund",
            id: "customerCategory",
            dataIndex: "customer_id",
            editor: customerCb,
            renderer: function(value, meta, record) { return record.get('customer'); }
        },
        {
            header: "Fastighetskategori",
            id: "columnCategory",
            dataIndex: 'premisescategory_id',
            editor: catCb,
               renderer: function(value, meta, record) { return record.get('category'); }
        }
    ]);

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Yes, but are you also using it as the selModel in the grid config?

  5. #5
    Sencha User
    Join Date
    Aug 2008
    Location
    Gothenburg
    Posts
    157
    Vote Rating
    2
    Dr. Flink is on a distinguished road

      0  

    Default


    @Condor: Thanks for helping!
    Quote Originally Posted by Condor View Post
    Yes, but are you also using it as the selModel in the grid config?
    Yes, I am. But if I don't do this I'm not able to select the checkboxes/rows?
    (I only want the user to be able to select rows through clicking the checkboxes.)
    Code:
    gridCmp = new Ext.grid.EditorGridPanel({
             id: 'centerGrid',
         clicksToEdit: 1,
         store: gridDs,
             cm: gridCm,
             sm: gridSm,
             ...
             ...
    });

  6. #6
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Remove the line:
    Code:
    sm: gridSm,
    It will use the default CellSelectionModel instead (or you could assign a RowSelectionModel if you prefer that).

  7. #7
    Sencha User
    Join Date
    Aug 2008
    Location
    Gothenburg
    Posts
    157
    Vote Rating
    2
    Dr. Flink is on a distinguished road

      0  

    Default


    I've allready tried removing this line. But if I do, I can't select the checkboxes at all any more...

  8. #8
    Ext User
    Join Date
    Mar 2008
    Posts
    15
    Vote Rating
    0
    haisrinu143 is on a distinguished road

      0  

    Question Handling CheckboxSelection Model and RowSelectionModel in GridPanel

    Handling CheckboxSelection Model and RowSelectionModel in GridPanel


    I would like to fire two events from my grid.

    1) Be able to select multiple rows when I select checkboxes in the first column

    2) Be able to open a popup window on click of any row

    Basically, I want to seperate out CheckboxSelectionModel and RowSelectionModel in GridPanel.

    Please let me know if you have a solution.

    Thanks in advance.

    Sai Srinivas.

  9. #9
    Sencha User
    Join Date
    Aug 2008
    Location
    Gothenburg
    Posts
    157
    Vote Rating
    2
    Dr. Flink is on a distinguished road

      0  

    Default


    I noticed that the grids rowmousedown is triggered before the CheckboxSelectionModel beforeselect fires.
    My workaround is to store a flag. This flag/variable I named hinderSelection, and I set it to be true when the rowmousedown fires.
    In the checkboxselectionmodel, I make a check if the hinderSelection is true, if it is I'll return false (this hinders the selection) and I also set the hinderSelection to be false (else I'll never be able to select any rows).

    Code:
    var hinderSelection = false; // Create the flag
    
    var gridSm = new Ext.grid.CheckboxSelectionModel({
        listeners: {
            beforerowselect: function(o, rowIndex, keepExisting, record) {
                if(hinderSelection) {
                    hinderSelection = false;
                    return false;
                }
            }
        }
    });
    
    var gridCmp = new Ext.grid.EditorGridPanel({
        // Grid config...
        //...
        //...
    
        listeners: {
            rowmousedown: function() {
                hinderSelection = true;
            }
        }
    });
    ...and, the rowmousedown event never fires when you click on the checkbox column. So, the only thing to do to make the popup is to add some rows to the rowmousedown listener, or the cellclick listener if you also want to know what column or cell the user clicked (not just the row).

    Hope this helps

  10. #10
    Sencha User
    Join Date
    Nov 2008
    Location
    Pune
    Posts
    43
    Vote Rating
    0
    tameshwar is on a distinguished road

      0  

    Default GridCheckboxSelModel

    GridCheckboxSelModel


    Hope this will fit to your requirement.

    new Ext.grid.CheckboxSelectionModel({
    checkOnly: true
    ,singleSelect:false
    ,listeners:{
    selectionchange: function() {
    var selectedRows = compnent.grid.getSelectionModel().getSelections();
    if(selectedRows.length > 1){
    Ext.getCmp('editButton').disable();
    }
    else{
    Ext.getCmp('editButton').enable();
    }
    }
    }
    });