/**
* @class Ext.selection.RowModel
* @extends Ext.selection.Model
- *
- * Implement row based navigation via keyboard.
- *
- * Must synchronize across grid sections
*/
Ext.define('Ext.selection.RowModel', {
extend: 'Ext.selection.Model',
/**
* @cfg {Boolean} enableKeyNav
*
- * Turns on/off keyboard navigation within the grid. Defaults to true.
+ * Turns on/off keyboard navigation within the grid.
*/
enableKeyNav: true,
+
+ /**
+ * @cfg {Boolean} [ignoreRightMouseSelection=true]
+ * True to ignore selections that are made when using the right mouse button if there are
+ * records that are already selected. If no records are selected, selection will continue
+ * as normal
+ */
+ ignoreRightMouseSelection: true,
constructor: function(){
this.addEvents(
* @event beforedeselect
* Fired before a record is deselected. If any listener returns false, the
* deselection is cancelled.
- * @param {Ext.selection.RowSelectionModel} this
+ * @param {Ext.selection.RowModel} this
* @param {Ext.data.Model} record The deselected record
* @param {Number} index The row index deselected
*/
* @event beforeselect
* Fired before a record is selected. If any listener returns false, the
* selection is cancelled.
- * @param {Ext.selection.RowSelectionModel} this
+ * @param {Ext.selection.RowModel} this
* @param {Ext.data.Model} record The selected record
* @param {Number} index The row index selected
*/
/**
* @event deselect
* Fired after a record is deselected
- * @param {Ext.selection.RowSelectionModel} this
+ * @param {Ext.selection.RowModel} this
* @param {Ext.data.Model} record The deselected record
* @param {Number} index The row index deselected
*/
/**
* @event select
* Fired after a record is selected
- * @param {Ext.selection.RowSelectionModel} this
+ * @param {Ext.selection.RowModel} this
* @param {Ext.data.Model} record The selected record
* @param {Number} index The row index selected
*/
// we can take into account ctrlKey, shiftKey, etc
onRowMouseDown: function(view, record, item, index, e) {
view.el.focus();
+ if (!this.allowRightMouseSelection(e)) {
+ return;
+ }
this.selectWithEvent(record, e);
},
+
+ /**
+ * Checks whether a selection should proceed based on the ignoreRightMouseSelection
+ * option.
+ * @private
+ * @param {Ext.EventObject} e The event
+ * @return {Boolean} False if the selection should not proceed
+ */
+ allowRightMouseSelection: function(e) {
+ var disallow = this.ignoreRightMouseSelection && e.button !== 0;
+ if (disallow) {
+ disallow = this.hasSelection();
+ }
+ return !disallow;
+ },
// Allow the GridView to update the UI by
// adding/removing a CSS class from the row.