-<!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-selection.Model'>/**
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>The source code</title>
+ <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../prettify/prettify.js"></script>
+ <style type="text/css">
+ .highlight { display: block; background-color: #ddd; }
+ </style>
+ <script type="text/javascript">
+ function highlight() {
+ document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+ }
+ </script>
+</head>
+<body onload="prettyPrint(); highlight();">
+ <pre class="prettyprint lang-js"><span id='Ext-selection-Model'>/**
</span> * @class Ext.selection.Model
* @extends Ext.util.Observable
*
requires: ['Ext.data.StoreManager'],
// lastSelected
-<span id='Ext-selection.Model-cfg-mode'> /**
+<span id='Ext-selection-Model-cfg-mode'> /**
</span> * @cfg {String} mode
* Modes of selection.
* Valid values are SINGLE, SIMPLE, and MULTI. Defaults to 'SINGLE'
*/
-<span id='Ext-selection.Model-cfg-allowDeselect'> /**
+<span id='Ext-selection-Model-cfg-allowDeselect'> /**
</span> * @cfg {Boolean} allowDeselect
* Allow users to deselect a record in a DataView, List or Grid. Only applicable when the SelectionModel's mode is 'SINGLE'. Defaults to false.
*/
allowDeselect: false,
-<span id='Ext-selection.Model-property-selected'> /**
+<span id='Ext-selection-Model-property-selected'> /**
</span> * @property selected
* READ-ONLY A MixedCollection that maintains all of the currently selected
* records.
selected: null,
-<span id='Ext-selection.Model-property-pruneRemoved'> /**
+<span id='Ext-selection-Model-property-pruneRemoved'> /**
</span> * Prune records when they are removed from the store from the selection.
* This is a private flag. For an example of its usage, take a look at
* Ext.selection.TreeModel.
Ext.apply(me, cfg);
me.addEvents(
-<span id='Ext-selection.Model-event-selectionchange'> /**
+<span id='Ext-selection-Model-event-selectionchange'> /**
</span> * @event selectionchange
* Fired after a selection change has occurred
* @param {Ext.selection.Model} this
}
},
- selectAll: function(silent) {
- var selections = this.store.getRange(),
+<span id='Ext-selection-Model-method-selectAll'> /**
+</span> * Select all records in the view.
+ * @param {Boolean} suppressEvent True to suppress any selects event
+ */
+ selectAll: function(suppressEvent) {
+ var me = this,
+ selections = me.store.getRange(),
i = 0,
- len = selections.length;
+ len = selections.length,
+ start = me.getSelection().length;
+ me.bulkChange = true;
for (; i < len; i++) {
- this.doSelect(selections[i], true, silent);
+ me.doSelect(selections[i], true, suppressEvent);
}
+ delete me.bulkChange;
+ // fire selection change only if the number of selections differs
+ me.maybeFireSelectionChange(me.getSelection().length !== start);
},
- deselectAll: function() {
- var selections = this.getSelection(),
+<span id='Ext-selection-Model-method-deselectAll'> /**
+</span> * Deselect all records in the view.
+ * @param {Boolean} suppressEvent True to suppress any deselect events
+ */
+ deselectAll: function(suppressEvent) {
+ var me = this,
+ selections = me.getSelection(),
i = 0,
- len = selections.length;
+ len = selections.length,
+ start = me.getSelection().length;
+ me.bulkChange = true;
for (; i < len; i++) {
- this.doDeselect(selections[i]);
+ me.doDeselect(selections[i], suppressEvent);
}
+ delete me.bulkChange;
+ // fire selection change only if the number of selections differs
+ me.maybeFireSelectionChange(me.getSelection().length !== start);
},
// Provides differentiation of logic between MULTI, SIMPLE and SINGLE
}
},
-<span id='Ext-selection.Model-method-selectRange'> /**
+<span id='Ext-selection-Model-method-selectRange'> /**
</span> * Selects a range of rows if the selection model {@link #isLocked is not locked}.
* All rows in between startRow and endRow are also selected.
* @param {Ext.data.Model/Number} startRow The record or index of the first row in the range
me.doMultiSelect(records, true);
},
-<span id='Ext-selection.Model-method-select'> /**
+<span id='Ext-selection-Model-method-select'> /**
</span> * Selects a record instance by record instance or index.
* @param {Ext.data.Model/Index} records An array of records or an index
* @param {Boolean} keepExisting
this.doSelect(records, keepExisting, suppressEvent);
},
-<span id='Ext-selection.Model-method-deselect'> /**
+<span id='Ext-selection-Model-method-deselect'> /**
</span> * Deselects a record instance by record instance or index.
* @param {Ext.data.Model/Index} records An array of records or an index
* @param {Boolean} suppressEvent Set to false to not fire a deselect event
len = records.length;
if (!keepExisting && selected.getCount() > 0) {
change = true;
- me.doDeselect(me.getSelection(), true);
+ me.doDeselect(me.getSelection(), suppressEvent);
}
for (; i < len; i++) {
me.maybeFireSelectionChange(!suppressEvent);
},
-<span id='Ext-selection.Model-method-setLastFocused'> /**
+<span id='Ext-selection-Model-method-setLastFocused'> /**
</span> * @param {Ext.data.Model} record
* Set a record as the last focused record. This does NOT mean
* that the record has been selected.
me.onLastFocusChanged(recordBeforeLast, record, supressFocus);
},
-<span id='Ext-selection.Model-method-isFocused'> /**
+<span id='Ext-selection-Model-method-isFocused'> /**
</span> * Determines if this record is currently focused.
* @param Ext.data.Record record
*/
// fire selection change as long as true is not passed
// into maybeFireSelectionChange
maybeFireSelectionChange: function(fireEvent) {
- if (fireEvent) {
- var me = this;
+ var me = this;
+ if (fireEvent && !me.bulkChange) {
me.fireEvent('selectionchange', me, me.getSelection());
}
},
-<span id='Ext-selection.Model-method-getLastSelected'> /**
+<span id='Ext-selection-Model-method-getLastSelected'> /**
</span> * Returns the last selected record.
*/
getLastSelected: function() {
return this.lastFocused;
},
-<span id='Ext-selection.Model-method-getSelection'> /**
+<span id='Ext-selection-Model-method-getSelection'> /**
</span> * Returns an array of the currently selected records.
*/
getSelection: function() {
return this.selected.getRange();
},
-<span id='Ext-selection.Model-method-getSelectionMode'> /**
+<span id='Ext-selection-Model-method-getSelectionMode'> /**
</span> * Returns the current selectionMode. SINGLE, MULTI or SIMPLE.
*/
getSelectionMode: function() {
return this.selectionMode;
},
-<span id='Ext-selection.Model-method-setSelectionMode'> /**
+<span id='Ext-selection-Model-method-setSelectionMode'> /**
</span> * Sets the current selectionMode. SINGLE, MULTI or SIMPLE.
*/
setSelectionMode: function(selMode) {
this.selectionMode = this.modes[selMode] ? selMode : 'SINGLE';
},
-<span id='Ext-selection.Model-method-isLocked'> /**
+<span id='Ext-selection-Model-method-isLocked'> /**
</span> * Returns true if the selections are locked.
* @return {Boolean}
*/
return this.locked;
},
-<span id='Ext-selection.Model-method-setLocked'> /**
+<span id='Ext-selection-Model-method-setLocked'> /**
</span> * Locks the current selection and disables any changes from
* happening to the selection.
* @param {Boolean} locked
this.locked = !!locked;
},
-<span id='Ext-selection.Model-method-isSelected'> /**
+<span id='Ext-selection-Model-method-isSelected'> /**
</span> * Returns <tt>true</tt> if the specified row is selected.
* @param {Record/Number} record The record or index of the record to check
* @return {Boolean}
return this.selected.indexOf(record) !== -1;
},
-<span id='Ext-selection.Model-method-hasSelection'> /**
+<span id='Ext-selection-Model-method-hasSelection'> /**
</span> * Returns true if there is a selected record.
* @return {Boolean}
*/
me.maybeFireSelectionChange(change);
},
+<span id='Ext-selection-Model-method-clearSelections'> /**
+</span> * A fast reset of the selections without firing events, updating the ui, etc.
+ * For private usage only.
+ * @private
+ */
clearSelections: function() {
// reset the entire selection to nothing
var me = this;
bindComponent: function(cmp) {
}
-});</pre></pre></body></html>
\ No newline at end of file
+});</pre>
+</body>
+</html>