Roo/bootstrap/Table.js
authorAlan Knowles <alan@roojs.com>
Mon, 26 Jul 2021 04:43:57 +0000 (12:43 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 26 Jul 2021 04:43:57 +0000 (12:43 +0800)
Roo/bootstrap/Table.js

index f242ce6..5fd9052 100644 (file)
@@ -427,9 +427,22 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
         
         // we can honour xs/sm/md/xl  as widths...
         // we first have to decide what widht we are currently at...
-        var sz = Roo.bootstrap.getGridSize();
+        var sz = Roo.getGridSize();
+        
+        var total = 0;
+        var cols = []; // visable cols.
+        for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
+            var w = cm.getColumnWidth(i, sz);
+            if (w > 0) {
+                cols.push(i);
+            }
+            total += w;
+        }
         
         
+        var unitWidth = Math.floor(this.bodyEl.dom.clientWidth / total);
+        var rem = this.bodyEl.dom.clientWidth - (unitWidth * total);
+        var last = cols.pop();
         
         for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
             
@@ -438,11 +451,13 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
                 hidden = 'display:none;';
             }
             // we can honour xs/sm/md/xl ?
-            var w = cm.getColumnWidth(i, sz);
-            
-            
-            var width = "width:" + (cm.getColumnWidth(i) || 100) + "px;";
+            var w = cm.getColumnWidth(i, sz) * unitWidth;
+            // width should return a small number...
+            if (i == last) {
+                w+=rem; // add the remaining with..
+            }
             
+            var width = "width:" + w+ "px;";
             
             styles.push(
                     '#' , this.id , ' .x-col-' , i, " {\n", cm.config[i].css, width, "\n}\n",