Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / source / Model2.html
index 3ac66bb..18ddfd7 100644 (file)
@@ -1,4 +1,21 @@
-<!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
  *
@@ -19,19 +36,19 @@ Ext.define('Ext.selection.Model', {
     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.
@@ -39,7 +56,7 @@ Ext.define('Ext.selection.Model', {
     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.
@@ -54,7 +71,7 @@ Ext.define('Ext.selection.Model', {
         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
@@ -108,24 +125,44 @@ Ext.define('Ext.selection.Model', {
         }
     },
 
-    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 &lt; 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 &lt; 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
@@ -167,7 +204,7 @@ Ext.define('Ext.selection.Model', {
         }
     },
 
-<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
@@ -229,7 +266,7 @@ Ext.define('Ext.selection.Model', {
         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
@@ -239,7 +276,7 @@ Ext.define('Ext.selection.Model', {
         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
@@ -282,7 +319,7 @@ Ext.define('Ext.selection.Model', {
         len = records.length;
         if (!keepExisting &amp;&amp; selected.getCount() &gt; 0) {
             change = true;
-            me.doDeselect(me.getSelection(), true);
+            me.doDeselect(me.getSelection(), suppressEvent);
         }
 
         for (; i &lt; len; i++) {
@@ -357,7 +394,7 @@ Ext.define('Ext.selection.Model', {
         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.
@@ -369,7 +406,7 @@ Ext.define('Ext.selection.Model', {
         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
      */
@@ -381,13 +418,13 @@ Ext.define('Ext.selection.Model', {
     // 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 &amp;&amp; !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() {
@@ -398,21 +435,21 @@ Ext.define('Ext.selection.Model', {
         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) {
@@ -422,7 +459,7 @@ Ext.define('Ext.selection.Model', {
         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}
      */
@@ -430,7 +467,7 @@ Ext.define('Ext.selection.Model', {
         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
@@ -439,7 +476,7 @@ Ext.define('Ext.selection.Model', {
         this.locked = !!locked;
     },
 
-<span id='Ext-selection.Model-method-isSelected'>    /**
+<span id='Ext-selection-Model-method-isSelected'>    /**
 </span>     * Returns &lt;tt&gt;true&lt;/tt&gt; if the specified row is selected.
      * @param {Record/Number} record The record or index of the record to check
      * @return {Boolean}
@@ -449,7 +486,7 @@ Ext.define('Ext.selection.Model', {
         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}
      */
@@ -498,6 +535,11 @@ Ext.define('Ext.selection.Model', {
         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;
@@ -580,4 +622,6 @@ Ext.define('Ext.selection.Model', {
     bindComponent: function(cmp) {
 
     }
-});</pre></pre></body></html>
\ No newline at end of file
+});</pre>
+</body>
+</html>