Roo/bootstrap/Table.js
authorAlan Knowles <alan@roojs.com>
Mon, 26 Jul 2021 02:38:18 +0000 (10:38 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 26 Jul 2021 02:38:18 +0000 (10:38 +0800)
Roo/bootstrap/Table.js

index 6fb7160..ec08cf3 100644 (file)
@@ -84,7 +84,8 @@ Currently the Table  uses multiple headers to try and handle XL / Medium etc...
  * @cfg {Roo.bootstrap.PagingToolbar} footer  a paging toolbar
  * @cfg {Boolean} lazyLoad  auto load data while scrolling to the end (default false)
  * @cfg {Boolean} auto_hide_footer  auto hide footer if only one page (default false)
+ * @cfg {Boolean} enableColumnResize default true if columns can be resized (drag/drop)
+ * @cfg {Number} minColumnWidth default 50 pixels minimum column width 
  * 
  * @constructor
  * Create a new Table
@@ -257,15 +258,20 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
     loadMask : false,
     footerShow : true,
     headerShow : true,
+    enableColumnResize: true,
   
     rowSelection : false,
     cellSelection : false,
     layout : false,
+
+    minColumnWidth : 50,
     
     // Roo.Element - the tbody
     bodyEl: false,  // <tbody> Roo.Element - thead element    
     headEl: false,  // <thead> Roo.Element - thead element
-    proxy : false, // proxy element for dragging?
+    resizeProxy : false, // proxy element for dragging?
+
+
     
     container: false, // used by gridpanel...
     
@@ -397,10 +403,10 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
         this.relayEvents(this.bodyEl, ["mousedown","mouseup","mouseover","mouseout","keypress"]);
   
   
-        this.resizeProxy = this.el.createChild({ cls:"x-grid-resize-proxy", html: '&#160;' });
+        this.resizeProxy = Roo.get(document.body).createChild({ cls:"x-grid-resize-proxy", html: '&#160;' });
         
   
-        if(this.enableColumnResize !== false && Roo.grid.SplitDragZone){
+        if(this.headEl && this.enableColumnResize !== false && Roo.grid.SplitDragZone){
             new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
         }
         
@@ -658,7 +664,7 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
             var hh = '';
             
             if(typeof(config.sortable) != 'undefined' && config.sortable){
-                c.cls = 'sortable';
+                c.cls += ' sortable';
                 c.html = '<i class="fa"></i>' + c.html;
             }
             
@@ -738,7 +744,7 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
                 
             });
             // at the end?
-            c.html +=' <span class="roo-hd-split"></span>';
+            c.html +=' <span class="x-grid-split x-grid-split-' + i + '"></span>';
             
             
             header.cn.push(c)
@@ -1257,7 +1263,11 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
             })
         }
     },
-    
+    /**
+     * get the Row Index from a dom element.
+     * @param {Roo.Element} row The row to look for
+     * @returns {Number} the row
+     */
     getRowIndex : function(row)
     {
         var rowIndex = -1;
@@ -1271,6 +1281,19 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
         });
         
         return rowIndex;
+    },
+    /**
+     * get the Column Index from a dom element. (using regex on x-hcol-{colid})
+     * @param {domElement} cell to look for
+     * @returns {Number} the column
+     */
+    getCellIndex : function(cell)
+    {
+        var id = String(cell.className).match(Roo.bootstrap.Table.cellRE);
+        if(id){
+            return parseInt(id[1], 10);
+        }
+        return 0;
     },
      /**
      * Returns the grid's underlying element = used by panel.Grid
@@ -1457,7 +1480,8 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
     }
 });
 
+// currently only used to find the split on drag.. 
+Roo.bootstrap.Table.cellRE = /(?:.*?)x-grid-(?:hd|cell|split)-([\d]+)(?:.*?)/;
 
 /**
  * @depricated