-
8 Sep 2008 8:12 AM #1
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.
-
8 Sep 2008 11:46 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
This is normal behaviour, as long as you only use the CheckboxSelectionModel as column and not as selectionmodel.
-
8 Sep 2008 1:11 PM #3
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'); } } ]);
-
8 Sep 2008 8:58 PM #4Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
Yes, but are you also using it as the selModel in the grid config?
-
9 Sep 2008 2:32 AM #5
@Condor: Thanks for helping!
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, ... ... });
-
9 Sep 2008 3:26 AM #6Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
Remove the line:
It will use the default CellSelectionModel instead (or you could assign a RowSelectionModel if you prefer that).Code:sm: gridSm,
-
9 Sep 2008 3:31 AM #7
I've allready tried removing this line. But if I do, I can't select the checkboxes at all any more...
-
12 Sep 2008 9:44 AM #8
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.
-
12 Sep 2008 4:12 PM #9
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).
...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).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; } } });
Hope this helps
-
30 Apr 2012 5:28 AM #10
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();
}
}
}
});


Reply With Quote