buildSDK/dependancy_bootstrap.txt
[roojs1] / Roo / bootstrap / Table / RowSelectionModel.js
index 38e15e2..eaf7c33 100644 (file)
@@ -1,11 +1,8 @@
 
 /**
- * @extends Roo.bootstrap.Table.AbstractSelectionModel
- * @class Roo.bootstrap.Table.RowSelectionModel
- * The default SelectionModel used by {@link Roo.bootstrap.Table}.
- * It supports multiple selections and keyboard selection/navigation. 
- * @constructor
- * @param {Object} config
+ *  @deprecated
+ *
+ *  
  */
 
 Roo.bootstrap.Table.RowSelectionModel = function(config){
@@ -110,6 +107,9 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
             },
             scope: this
         });
+        this.grid.store.on('load', function(){
+            this.selections.clear();
+        },this);
         /*
         var view = this.grid.view;
         view.on("refresh", this.onRefresh, this);
@@ -119,9 +119,8 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
     },
 
     // private
-    onRefresh : function(){
-       //edited by KH Lau 9-Aug-2017
-        //var ds = this.grid.dataSource, i, v = this.grid.view;
+    onRefresh : function()
+    {
         var ds = this.grid.store, i, v = this.grid.view;
         var s = this.selections;
         s.each(function(r){
@@ -150,13 +149,12 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
      * @param {Array} records The records to select
      * @param {Boolean} keepExisting (optional) True to keep existing selections
      */
-    selectRecords : function(records, keepExisting){
+    selectRecords : function(records, keepExisting)
+    {
         if(!keepExisting){
             this.clearSelections();
         }
-       //edited by KH Lau 9-Aug-2017
-        //var ds = this.grid.dataSource;
-        var ds = this.grid.store;
+           var ds = this.grid.store;
         for(var i = 0, len = records.length; i < len; i++){
             this.selectRow(ds.indexOf(records[i]), true);
         }
@@ -190,10 +188,9 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
      * Selects the row immediately following the last selected row.
      * @param {Boolean} keepExisting (optional) True to keep existing selections
      */
-    selectNext : function(keepExisting){
-       //edited by KH Lau 9-Aug-2017
-        //if(this.last !== false && (this.last+1) < this.grid.dataSource.getCount()){
-        if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
+    selectNext : function(keepExisting)
+    {
+           if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
             this.selectRow(this.last+1, keepExisting);
             this.grid.getView().focusRow(this.last);
         }
@@ -230,14 +227,13 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
     /**
      * Clears all selections.
      */
-    clearSelections : function(fast){
+    clearSelections : function(fast)
+    {
         if(this.locked) {
             return;
         }
         if(fast !== true){
-           //edited by KH Lau 9-Aug-2017
-            //var ds = this.grid.dataSource;
-            var ds = this.grid.store;
+               var ds = this.grid.store;
             var s = this.selections;
             s.each(function(r){
                 this.deselectRow(ds.indexOfId(r.id));
@@ -258,8 +254,6 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
             return;
         }
         this.selections.clear();
-        //for(var i = 0, len = this.grid.dataSource.getCount(); i < len; i++){
-       //edited by KH Lau 9-Aug-2017
         for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
             this.selectRow(i, true);
         }
@@ -279,9 +273,7 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
      * @return {Boolean}
      */
     isSelected : function(index){
-       //edited by KH Lau 9-Aug-2017
-        //var r = typeof index == "number" ? this.grid.dataSource.getAt(index) : index;
-        var r = typeof index == "number" ? this.grid.store.getAt(index -1 ) : index;
+           var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
         return (r && this.selections.key(r.id) ? true : false);
     },
 
@@ -300,42 +292,38 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
        
     },
     // private
-    handleMouseDown : function(e, t){
-       //edited by KH Lau 9-Aug-2017
-        //var view = this.grid.getView(), rowIndex;
-        var rowIndex = t.dom.rowIndex;
-        if(this.isLocked() || rowIndex ==0 ){
+    handleMouseDown : function(e, t)
+    {
+           var rowIndex = this.grid.headerShow  ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
+        if(this.isLocked() || rowIndex < 0 ){
             return;
         };
         if(e.shiftKey && this.last !== false){
             var last = this.last;
             this.selectRange(last, rowIndex, e.ctrlKey);
             this.last = last; // reset the last
-           //edited by KH Lau 9-Aug-2017
-           t.focus();
-            //view.focusRow(rowIndex);
+            t.focus();
+    
         }else{
             var isSelected = this.isSelected(rowIndex);
-
+            //Roo.log("select row:" + rowIndex);
             if(isSelected){
                 this.deselectRow(rowIndex);
             } else {
-               //edited by KH Lau 9-Aug-2017
-                //this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
-                this.selectRow(rowIndex, true);
-           }
-           //edited by KH Lau 9-Aug-2017
-           /*
-            if(e.button !== 0 && isSelected){
-               alert('rowIndex 2: ' + rowIndex);
-                view.focusRow(rowIndex);
-            }else if(e.ctrlKey && isSelected){
-                this.deselectRow(rowIndex);
-            }else if(!isSelected){
-                this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
-                view.focusRow(rowIndex);
+                       this.selectRow(rowIndex, true);
             }
-           */
+    
+            /*
+                if(e.button !== 0 && isSelected){
+                alert('rowIndex 2: ' + rowIndex);
+                    view.focusRow(rowIndex);
+                }else if(e.ctrlKey && isSelected){
+                    this.deselectRow(rowIndex);
+                }else if(!isSelected){
+                    this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
+                    view.focusRow(rowIndex);
+                }
+            */
         }
         this.fireEvent("afterselectionchange", this);
     },
@@ -406,28 +394,26 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
      * @param {Number} row The index of the row to select
      * @param {Boolean} keepExisting (optional) True to keep existing selections
      */
-    selectRow : function(index, keepExisting, preventViewNotify){
-       //edited by KH Lau 9-Aug-2017
-        //if(this.locked || (index < 0 || index >= this.grid.dataSource.getCount())) {
-        if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
+    selectRow : function(index, keepExisting, preventViewNotify)
+    {
+           if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
             return;
         }
         if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
             if(!keepExisting || this.singleSelect){
                 this.clearSelections();
             }
-           //edited by KH Lau 9-Aug-2017
-            //var r = this.grid.dataSource.getAt(index);
-            var r = this.grid.store.getAt(index-1);
-           console.log('selectRow - record id :' + r.id);
-           //alert(r.id);
+           
+            var r = this.grid.store.getAt(index);
+            //console.log('selectRow - record id :' + r.id);
+            
             this.selections.add(r);
             this.last = this.lastActive = index;
             if(!preventViewNotify){
-               //edited by KH Lau 9-Aug-2017
-                //this.grid.getView().onRowSelect(index);
-               var proxy = new Roo.Element(this.grid.getEl().child('table',false).child('tbody',false).dom.childNodes[index -1]);
-               proxy.addClass('bg-success');
+                var proxy = new Roo.Element(
+                                this.grid.getRowDom(index)
+                );
+                proxy.addClass('bg-info info');
             }
             this.fireEvent("rowselect", this, index, r);
             this.fireEvent("selectionchange", this);
@@ -438,7 +424,8 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
      * Deselects a row.
      * @param {Number} row The index of the row to deselect
      */
-    deselectRow : function(index, preventViewNotify){
+    deselectRow : function(index, preventViewNotify)
+    {
         if(this.locked) {
             return;
         }
@@ -448,16 +435,20 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
         if(this.lastActive == index){
             this.lastActive = false;
         }
-       //edited by KH Lau 9-Aug-2017
-        var r = this.grid.store.getAt(index-1);
-        //var r = this.grid.dataSource.getAt(index);
+       
+        var r = this.grid.store.getAt(index);
+        if (!r) {
+            return;
+        }
+        
         this.selections.remove(r);
-       console.log('deselectRow - record id :' + r.id);
+        //.console.log('deselectRow - record id :' + r.id);
         if(!preventViewNotify){
-           //edited by KH Lau 9-Aug-2017
-            //this.grid.getView().onRowDeselect(index);
-           var proxy = new Roo.Element(this.grid.getEl().child('table',false).child('tbody',false).dom.childNodes[index -1]);
-           proxy.removeClass('bg-success');
+       
+           var proxy = new Roo.Element(
+                this.grid.getRowDom(index)
+            );
+            proxy.removeClass('bg-info info');
         }
         this.fireEvent("rowdeselect", this, index);
         this.fireEvent("selectionchange", this);