Hybrid View
-
11 Jun 2011 9:11 AM #1
simpleSelect on xtype:grid with selModel: RowSelectionModel -> Possible?
simpleSelect on xtype:grid with selModel: RowSelectionModel -> Possible?
I have a grid with an implied default selModel of RowSelectionModel, and implied default setting singleSelect = false, causing you to be able to select multiple rows of data.
In a gridView, the same would be done using multiSelect = true, which also gives you the optional feature called simpleSelect = true. This makes it so you aren't required to hold ctrl for a multi-selection.
Is there an easy way to have simpleSelect for a grid with RowSelectionModel? It's not in the documentation, but I was hoping there is a relatively simple trick to enable this. I'd reckon this is a popular feature and I'm probably missing something, but I can't figure it out using google.
-
12 Jun 2011 2:34 AM #2
I don't know of anything simple but here's something that seems to work:
Code:new Ext.grid.GridPanel({ ... listeners: { rowmousedown: function(grid, rowIndex, ev) { var selModel = grid.getSelectionModel(); if (ev.button !== 0 || selModel.isLocked()){ return; } if (selModel.isSelected(rowIndex)) { selModel.deselectRow(rowIndex); } else { selModel.selectRow(rowIndex, true); } return false; } } });
-
12 Jun 2011 6:10 AM #3
Thank you good Sir! This does pretty much exactly the trick.
I didn't know rowmousedown was a proper event. I did try to look up all available events; the API documentation is awesome, but I have not yet succeeded in securing a list of available events.
I hope this simple extension will be available in ExtJS 4. Haven't yet migrated to 4 because I figured migrating existing ExtJS 3 code is more work than just keep using 3. For now.
-
12 Jun 2011 7:12 AM #4
That event is definitely documented:
http://dev.sencha.com/deploy/ext-3.4...grid.GridPanel
Scroll right down to the bottom... third row up.
-
12 Jun 2011 9:03 AM #5


Reply With Quote