Fix #6874 - Grid column resize
[roojs1] / Roo / bootstrap / Table / RowSelectionModel.js
index c635e2e..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);
@@ -273,7 +273,7 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
      * @return {Boolean}
      */
     isSelected : function(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);
     },
 
@@ -306,7 +306,7 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
     
         }else{
             var isSelected = this.isSelected(rowIndex);
-
+            //Roo.log("select row:" + rowIndex);
             if(isSelected){
                 this.deselectRow(rowIndex);
             } else {
@@ -413,7 +413,7 @@ Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSe
                 var proxy = new Roo.Element(
                                 this.grid.getRowDom(index)
                 );
-                proxy.addClass('bg-info');
+                proxy.addClass('bg-info info');
             }
             this.fireEvent("rowselect", this, index, r);
             this.fireEvent("selectionchange", this);
@@ -424,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;
         }
@@ -434,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);