Changed Roo/bootstrap/Table.js
[roojs1] / Roo / bootstrap / Table.js
1 /**
2  * @class Roo.bootstrap.Table
3  * @licence LGBL
4  * @extends Roo.bootstrap.Component
5  * @children Roo.bootstrap.TableBody
6  * Bootstrap Table class.  This class represents the primary interface of a component based grid control.
7  * Similar to Roo.grid.Grid
8  * <pre><code>
9  var table = Roo.factory({
10     xtype : 'Table',
11     xns : Roo.bootstrap,
12     autoSizeColumns: true,
13     
14     
15     store : {
16         xtype : 'Store',
17         xns : Roo.data,
18         remoteSort : true,
19         sortInfo : { direction : 'ASC', field: 'name' },
20         proxy : {
21            xtype : 'HttpProxy',
22            xns : Roo.data,
23            method : 'GET',
24            url : 'https://example.com/some.data.url.json'
25         },
26         reader : {
27            xtype : 'JsonReader',
28            xns : Roo.data,
29            fields : [ 'id', 'name', whatever' ],
30            id : 'id',
31            root : 'data'
32         }
33     },
34     cm : [
35         {
36             xtype : 'ColumnModel',
37             xns : Roo.grid,
38             align : 'center',
39             cursor : 'pointer',
40             dataIndex : 'is_in_group',
41             header : "Name",
42             sortable : true,
43             renderer : function(v, x , r) {  
44             
45                 return String.format("{0}", v)
46             }
47             width : 3
48         } // more columns..
49     ],
50     selModel : {
51         xtype : 'RowSelectionModel',
52         xns : Roo.bootstrap.Table
53         // you can add listeners to catch selection change here....
54     }
55      
56
57  });
58  // set any options
59  grid.render(Roo.get("some-div"));
60 </code></pre>
61
62 Currently the Table  uses multiple headers to try and handle XL / Medium etc... styling
63
64
65
66  *
67  * @cfg {Roo.grid.AbstractSelectionModel} sm The selection model to use (cell selection is not supported yet)
68  * @cfg {Roo.data.Store} store The data store to use
69  * @cfg {Roo.grid.ColumnModel} cm[] A column for the grid.
70  * 
71  * @cfg {String} cls table class
72  *
73  *
74  * @cfg {string} empty_results  Text to display for no results 
75  * @cfg {boolean} striped Should the rows be alternative striped
76  * @cfg {boolean} bordered Add borders to the table
77  * @cfg {boolean} hover Add hover highlighting
78  * @cfg {boolean} condensed Format condensed
79  * @cfg {boolean} responsive default false - if this is on, columns are rendered with col-xs-4 etc. classes, otherwise columns will be sized by CSS,
80  *                also adds table-responsive (see bootstrap docs for details)
81  * @cfg {Boolean} loadMask (true|false) default false
82  * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
83  * @cfg {Boolean} headerShow (true|false) generate thead, default true
84  * @cfg {Boolean} rowSelection (true|false) default false
85  * @cfg {Boolean} cellSelection (true|false) default false
86  * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header (with resizable columns)
87  * @cfg {Roo.bootstrap.PagingToolbar} footer  a paging toolbar
88  * @cfg {Boolean} lazyLoad  auto load data while scrolling to the end (default false)
89  * @cfg {Boolean} auto_hide_footer  auto hide footer if only one page (default false)
90  * @cfg {Boolean} enableColumnResize default true if columns can be resized = needs scrollBody to be set to work (drag/drop)
91  * @cfg {Boolean} disableAutoSize disable auto size
92  *
93  * 
94  * @cfg {Number} minColumnWidth default 50 pixels minimum column width 
95  * 
96  * @constructor
97  * Create a new Table
98  * @param {Object} config The config object
99  */
100
101 Roo.bootstrap.Table = function(config)
102 {
103     Roo.bootstrap.Table.superclass.constructor.call(this, config);
104      
105     // BC...
106     this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
107     this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
108     this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
109     this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
110     
111     this.view = this; // compat with grid.
112     
113     this.sm = this.sm || {xtype: 'RowSelectionModel'};
114     if (this.sm) {
115         this.sm.grid = this;
116         this.selModel = Roo.factory(this.sm, Roo.grid);
117         this.sm = this.selModel;
118         this.sm.xmodule = this.xmodule || false;
119     }
120     
121     if (this.cm && typeof(this.cm.config) == 'undefined') {
122         this.colModel = new Roo.grid.ColumnModel(this.cm);
123         this.cm = this.colModel;
124         this.cm.xmodule = this.xmodule || false;
125     }
126     if (this.store) {
127         this.store= Roo.factory(this.store, Roo.data);
128         this.ds = this.store;
129         this.ds.xmodule = this.xmodule || false;
130          
131     }
132     if (this.footer && this.store) {
133         this.footer.dataSource = this.ds;
134         this.footer = Roo.factory(this.footer);
135     }
136     
137     /** @private */
138     this.addEvents({
139         /**
140          * @event cellclick
141          * Fires when a cell is clicked
142          * @param {Roo.bootstrap.Table} this
143          * @param {Roo.Element} el
144          * @param {Number} rowIndex
145          * @param {Number} columnIndex
146          * @param {Roo.EventObject} e
147          */
148         "cellclick" : true,
149         /**
150          * @event celldblclick
151          * Fires when a cell is double clicked
152          * @param {Roo.bootstrap.Table} this
153          * @param {Roo.Element} el
154          * @param {Number} rowIndex
155          * @param {Number} columnIndex
156          * @param {Roo.EventObject} e
157          */
158         "celldblclick" : true,
159         /**
160          * @event rowclick
161          * Fires when a row is clicked
162          * @param {Roo.bootstrap.Table} this
163          * @param {Roo.Element} el
164          * @param {Number} rowIndex
165          * @param {Roo.EventObject} e
166          */
167         "rowclick" : true,
168         /**
169          * @event rowdblclick
170          * Fires when a row is double clicked
171          * @param {Roo.bootstrap.Table} this
172          * @param {Roo.Element} el
173          * @param {Number} rowIndex
174          * @param {Roo.EventObject} e
175          */
176         "rowdblclick" : true,
177         /**
178          * @event mouseover
179          * Fires when a mouseover occur
180          * @param {Roo.bootstrap.Table} this
181          * @param {Roo.Element} el
182          * @param {Number} rowIndex
183          * @param {Number} columnIndex
184          * @param {Roo.EventObject} e
185          */
186         "mouseover" : true,
187         /**
188          * @event mouseout
189          * Fires when a mouseout occur
190          * @param {Roo.bootstrap.Table} this
191          * @param {Roo.Element} el
192          * @param {Number} rowIndex
193          * @param {Number} columnIndex
194          * @param {Roo.EventObject} e
195          */
196         "mouseout" : true,
197         /**
198          * @event rowclass
199          * Fires when a row is rendered, so you can change add a style to it.
200          * @param {Roo.bootstrap.Table} this
201          * @param {Object} rowcfg   contains record  rowIndex colIndex and rowClass - set rowClass to add a style.
202          */
203         'rowclass' : true,
204           /**
205          * @event rowsrendered
206          * Fires when all the  rows have been rendered
207          * @param {Roo.bootstrap.Table} this
208          */
209         'rowsrendered' : true,
210         /**
211          * @event contextmenu
212          * The raw contextmenu event for the entire grid.
213          * @param {Roo.EventObject} e
214          */
215         "contextmenu" : true,
216         /**
217          * @event rowcontextmenu
218          * Fires when a row is right clicked
219          * @param {Roo.bootstrap.Table} this
220          * @param {Number} rowIndex
221          * @param {Roo.EventObject} e
222          */
223         "rowcontextmenu" : true,
224         /**
225          * @event cellcontextmenu
226          * Fires when a cell is right clicked
227          * @param {Roo.bootstrap.Table} this
228          * @param {Number} rowIndex
229          * @param {Number} cellIndex
230          * @param {Roo.EventObject} e
231          */
232          "cellcontextmenu" : true,
233          /**
234          * @event headercontextmenu
235          * Fires when a header is right clicked
236          * @param {Roo.bootstrap.Table} this
237          * @param {Number} columnIndex
238          * @param {Roo.EventObject} e
239          */
240         "headercontextmenu" : true,
241         /**
242          * @event mousedown
243          * The raw mousedown event for the entire grid.
244          * @param {Roo.EventObject} e
245          */
246         "mousedown" : true
247         
248     });
249 };
250
251 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
252     
253     cls: false,
254     
255     empty_results : '',
256     striped : false,
257     scrollBody : false,
258     bordered: false,
259     hover:  false,
260     condensed : false,
261     responsive : false,
262     sm : false,
263     cm : false,
264     store : false,
265     loadMask : false,
266     footerShow : true,
267     headerShow : true,
268     enableColumnResize: true,
269   
270     rowSelection : false,
271     cellSelection : false,
272     layout : false,
273
274     minColumnWidth : 50,
275     
276     // Roo.Element - the tbody
277     bodyEl: false,  // <tbody> Roo.Element - thead element    
278     headEl: false,  // <thead> Roo.Element - thead element
279     resizeProxy : false, // proxy element for dragging?
280
281
282     
283     container: false, // used by gridpanel...
284     
285     lazyLoad : false,
286     
287     CSS : Roo.util.CSS,
288     
289     auto_hide_footer : false,
290     
291     view: false, // actually points to this..
292     
293     getAutoCreate : function()
294     {
295         var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
296         
297         cfg = {
298             tag: 'table',
299             cls : 'table', 
300             cn : []
301         };
302         // this get's auto added by panel.Grid
303         if (this.scrollBody) {
304             cfg.cls += ' table-body-fixed';
305         }    
306         if (this.striped) {
307             cfg.cls += ' table-striped';
308         }
309         
310         if (this.hover) {
311             cfg.cls += ' table-hover';
312         }
313         if (this.bordered) {
314             cfg.cls += ' table-bordered';
315         }
316         if (this.condensed) {
317             cfg.cls += ' table-condensed';
318         }
319         
320         if (this.responsive) {
321             cfg.cls += ' table-responsive';
322         }
323         
324         if (this.cls) {
325             cfg.cls+=  ' ' +this.cls;
326         }
327         
328         
329         
330         if (this.layout) {
331             cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
332         }
333         
334         if(this.store || this.cm){
335             if(this.headerShow){
336                 cfg.cn.push(this.renderHeader());
337             }
338             
339             cfg.cn.push(this.renderBody());
340             
341             if(this.footerShow){
342                 cfg.cn.push(this.renderFooter());
343             }
344             // where does this come from?
345             //cfg.cls+=  ' TableGrid';
346         }
347         
348         return { cn : [ cfg ] };
349     },
350     
351     initEvents : function()
352     {   
353         if(!this.store || !this.cm){
354             return;
355         }
356         if (this.selModel) {
357             this.selModel.initEvents();
358         }
359         
360         
361         //Roo.log('initEvents with ds!!!!');
362         
363         this.bodyEl = this.el.select('tbody', true).first();
364         this.headEl = this.el.select('thead', true).first();
365         this.mainFoot = this.el.select('tfoot', true).first();
366         
367         
368         
369         
370         Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
371             e.on('click', this.sort, this);
372         }, this);
373         
374         
375         // why is this done????? = it breaks dialogs??
376         //this.parent().el.setStyle('position', 'relative');
377         
378         
379         if (this.footer) {
380             this.footer.parentId = this.id;
381             this.footer.onRender(this.el.select('tfoot tr td').first(), null);
382             
383             if(this.lazyLoad){
384                 this.el.select('tfoot tr td').first().addClass('hide');
385             }
386         } 
387         
388         if(this.loadMask) {
389             this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
390         }
391         
392         this.store.on('load', this.onLoad, this);
393         this.store.on('beforeload', this.onBeforeLoad, this);
394         this.store.on('update', this.onUpdate, this);
395         this.store.on('add', this.onAdd, this);
396         this.store.on("clear", this.clear, this);
397         
398         this.el.on("contextmenu", this.onContextMenu, this);
399         
400         
401         this.cm.on("headerchange", this.onHeaderChange, this);
402         this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
403
404  //?? does bodyEl get replaced on render?
405         this.bodyEl.on("click", this.onClick, this);
406         this.bodyEl.on("dblclick", this.onDblClick, this);        
407         this.bodyEl.on('scroll', this.onBodyScroll, this);
408
409         // guessing mainbody will work - this relays usually caught by selmodel at present.
410         this.relayEvents(this.bodyEl, ["mousedown","mouseup","mouseover","mouseout","keypress"]);
411   
412   
413         this.resizeProxy = Roo.get(document.body).createChild({ cls:"x-grid-resize-proxy", html: '&#160;' });
414         
415   
416         if(this.headEl && this.enableColumnResize !== false && Roo.grid.SplitDragZone){
417             new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
418         }
419         
420         this.initCSS();
421     },
422     // Compatibility with grid - we implement all the view features at present.
423     getView : function()
424     {
425         return this;
426     },
427     
428     initCSS : function()
429     {
430         
431         
432         var cm = this.cm, styles = [];
433         this.CSS.removeStyleSheet(this.id + '-cssrules');
434         var headHeight = this.headEl ? this.headEl.dom.clientHeight : 0;
435         // we can honour xs/sm/md/xl  as widths...
436         // we first have to decide what widht we are currently at...
437         var sz = Roo.getGridSize();
438         
439         var total = 0;
440         var last = -1;
441         var cols = []; // visable cols.
442         var total_abs = 0;
443         for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
444             var w = cm.getColumnWidth(i, false);
445             if(cm.isHidden(i)){
446                 cols.push( { rel : false, abs : 0 });
447                 continue;
448             }
449             if (w !== false) {
450                 cols.push( { rel : false, abs : w });
451                 total_abs += w;
452                 last = i; // not really..
453                 continue;
454             }
455             var w = cm.getColumnWidth(i, sz);
456             if (w > 0) {
457                 last = i
458             }
459             total += w;
460             cols.push( { rel : w, abs : false });
461         }
462         
463         var avail = this.bodyEl.dom.clientWidth - total_abs;
464         
465         var unitWidth = Math.floor(avail / total);
466         var rem = avail - (unitWidth * total);
467         
468         var hidden, width, pos = 0 , splithide , left;
469         for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
470             
471             hidden = 'display:none;';
472             left = '';
473             width  = 'width:0px;';
474             splithide = '';
475             if(!cm.isHidden(i)){
476                 hidden = '';
477                 
478                 
479                 // we can honour xs/sm/md/xl ?
480                 var w = cols[i].rel == false ? cols[i].abs : (cols[i].rel * unitWidth);
481                 if (w===0) {
482                     hidden = 'display:none;';
483                 }
484                 // width should return a small number...
485                 if (i == last) {
486                     w+=rem; // add the remaining with..
487                 }
488                 pos += w;
489                 left = "left:" + (pos -4) + "px;";
490                 width = "width:" + w+ "px;";
491                 
492             }
493             if (this.responsive) {
494                 width = '';
495                 left = '';
496                 hidden = cm.isHidden(i) ? 'display:none;' : '';
497                 splithide = 'display: none;';
498             }
499             
500             styles.push( '#' , this.id , ' .x-col-' , i, " {", cm.config[i].css, width, hidden, "}\n" );
501             if (this.headEl) {
502                 if (i == last) {
503                     splithide = 'display:none;';
504                 }
505                 
506                 styles.push('#' , this.id , ' .x-hcol-' , i, " { ", width, hidden," }\n",
507                             '#' , this.id , ' .x-grid-split-' , i, " { ", left, splithide, 'height:', (headHeight - 4), "px;}\n",
508                             // this is the popover version..
509                             '.popover-inner #' , this.id , ' .x-grid-split-' , i, " { ", left, splithide, 'height:', 100, "%;}\n"
510                 );
511             }
512             
513         }
514         //Roo.log(styles.join(''));
515         this.CSS.createStyleSheet( styles.join(''), this.id + '-cssrules');
516         
517     },
518     
519     
520     
521     onContextMenu : function(e, t)
522     {
523         this.processEvent("contextmenu", e);
524     },
525     
526     processEvent : function(name, e)
527     {
528         if (name != 'touchstart' ) {
529             this.fireEvent(name, e);    
530         }
531         
532         var t = e.getTarget();
533         
534         var cell = Roo.get(t);
535         
536         if(!cell){
537             return;
538         }
539         
540         if(cell.findParent('tfoot', false, true)){
541             return;
542         }
543         
544         if(cell.findParent('thead', false, true)){
545             
546             if(e.getTarget().nodeName.toLowerCase() != 'th'){
547                 cell = Roo.get(t).findParent('th', false, true);
548                 if (!cell) {
549                     Roo.log("failed to find th in thead?");
550                     Roo.log(e.getTarget());
551                     return;
552                 }
553             }
554             
555             var cellIndex = cell.dom.cellIndex;
556             
557             var ename = name == 'touchstart' ? 'click' : name;
558             this.fireEvent("header" + ename, this, cellIndex, e);
559             
560             return;
561         }
562         
563         if(e.getTarget().nodeName.toLowerCase() != 'td'){
564             cell = Roo.get(t).findParent('td', false, true);
565             if (!cell) {
566                 Roo.log("failed to find th in tbody?");
567                 Roo.log(e.getTarget());
568                 return;
569             }
570         }
571         
572         var row = cell.findParent('tr', false, true);
573         var cellIndex = cell.dom.cellIndex;
574         var rowIndex = row.dom.rowIndex - 1;
575         
576         if(row !== false){
577             
578             this.fireEvent("row" + name, this, rowIndex, e);
579             
580             if(cell !== false){
581             
582                 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
583             }
584         }
585         
586     },
587     
588     onMouseover : function(e, el)
589     {
590         var cell = Roo.get(el);
591         
592         if(!cell){
593             return;
594         }
595         
596         if(e.getTarget().nodeName.toLowerCase() != 'td'){
597             cell = cell.findParent('td', false, true);
598         }
599         
600         var row = cell.findParent('tr', false, true);
601         var cellIndex = cell.dom.cellIndex;
602         var rowIndex = row.dom.rowIndex - 1; // start from 0
603         
604         this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
605         
606     },
607     
608     onMouseout : function(e, el)
609     {
610         var cell = Roo.get(el);
611         
612         if(!cell){
613             return;
614         }
615         
616         if(e.getTarget().nodeName.toLowerCase() != 'td'){
617             cell = cell.findParent('td', false, true);
618         }
619         
620         var row = cell.findParent('tr', false, true);
621         var cellIndex = cell.dom.cellIndex;
622         var rowIndex = row.dom.rowIndex - 1; // start from 0
623         
624         this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
625         
626     },
627     
628     onClick : function(e, el)
629     {
630         var cell = Roo.get(el);
631         
632         if(!cell || (!this.cellSelection && !this.rowSelection)){
633             return;
634         }
635         
636         if(e.getTarget().nodeName.toLowerCase() != 'td'){
637             cell = cell.findParent('td', false, true);
638         }
639         
640         if(!cell || typeof(cell) == 'undefined'){
641             return;
642         }
643         
644         var row = cell.findParent('tr', false, true);
645         
646         if(!row || typeof(row) == 'undefined'){
647             return;
648         }
649         
650         var cellIndex = cell.dom.cellIndex;
651         var rowIndex = this.getRowIndex(row);
652         
653         // why??? - should these not be based on SelectionModel?
654         //if(this.cellSelection){
655             this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
656         //}
657         
658         //if(this.rowSelection){
659             this.fireEvent('rowclick', this, row, rowIndex, e);
660         //}
661          
662     },
663         
664     onDblClick : function(e,el)
665     {
666         var cell = Roo.get(el);
667         
668         if(!cell || (!this.cellSelection && !this.rowSelection)){
669             return;
670         }
671         
672         if(e.getTarget().nodeName.toLowerCase() != 'td'){
673             cell = cell.findParent('td', false, true);
674         }
675         
676         if(!cell || typeof(cell) == 'undefined'){
677             return;
678         }
679         
680         var row = cell.findParent('tr', false, true);
681         
682         if(!row || typeof(row) == 'undefined'){
683             return;
684         }
685         
686         var cellIndex = cell.dom.cellIndex;
687         var rowIndex = this.getRowIndex(row);
688         
689         if(this.cellSelection){
690             this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
691         }
692         
693         if(this.rowSelection){
694             this.fireEvent('rowdblclick', this, row, rowIndex, e);
695         }
696     },
697     findRowIndex : function(el)
698     {
699         var cell = Roo.get(el);
700         if(!cell) {
701             return false;
702         }
703         var row = cell.findParent('tr', false, true);
704         
705         if(!row || typeof(row) == 'undefined'){
706             return false;
707         }
708         return this.getRowIndex(row);
709     },
710     sort : function(e,el)
711     {
712         var col = Roo.get(el);
713         
714         if(!col.hasClass('sortable')){
715             return;
716         }
717         
718         var sort = col.attr('sort');
719         var dir = 'ASC';
720         
721         if(col.select('i', true).first().hasClass('fa-arrow-up')){
722             dir = 'DESC';
723         }
724         
725         this.store.sortInfo = {field : sort, direction : dir};
726         
727         if (this.footer) {
728             Roo.log("calling footer first");
729             this.footer.onClick('first');
730         } else {
731         
732             this.store.load({ params : { start : 0 } });
733         }
734     },
735     
736     renderHeader : function()
737     {
738         var header = {
739             tag: 'thead',
740             cn : []
741         };
742         
743         var cm = this.cm;
744         this.totalWidth = 0;
745         
746         for(var i = 0, len = cm.getColumnCount(); i < len; i++){
747             
748             var config = cm.config[i];
749             
750             var c = {
751                 tag: 'th',
752                 cls : 'x-hcol-' + i,
753                 style : '',
754                 
755                 html: cm.getColumnHeader(i)
756             };
757             
758             var tooltip = cm.getColumnTooltip(i);
759             if (tooltip) {
760                 c.tooltip = tooltip;
761             }
762             
763             
764             var hh = '';
765             
766             if(typeof(config.sortable) != 'undefined' && config.sortable){
767                 c.cls += ' sortable';
768                 c.html = '<i class="fa"></i>' + c.html;
769             }
770             
771             // could use BS4 hidden-..-down 
772             
773             if(typeof(config.lgHeader) != 'undefined'){
774                 hh += '<span class="hidden-xs hidden-sm hidden-md ">' + config.lgHeader + '</span>';
775             }
776             
777             if(typeof(config.mdHeader) != 'undefined'){
778                 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
779             }
780             
781             if(typeof(config.smHeader) != 'undefined'){
782                 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
783             }
784             
785             if(typeof(config.xsHeader) != 'undefined'){
786                 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
787             }
788             
789             if(hh.length){
790                 c.html = hh;
791             }
792             
793             if(typeof(config.tooltip) != 'undefined'){
794                 c.tooltip = config.tooltip;
795             }
796             
797             if(typeof(config.colspan) != 'undefined'){
798                 c.colspan = config.colspan;
799             }
800             
801             // hidden is handled by CSS now
802             
803             if(typeof(config.dataIndex) != 'undefined'){
804                 c.sort = config.dataIndex;
805             }
806             
807            
808             
809             if(typeof(config.align) != 'undefined' && config.align.length){
810                 c.style += ' text-align:' + config.align + ';';
811             }
812             
813             /* width is done in CSS
814              *if(typeof(config.width) != 'undefined'){
815                 c.style += ' width:' + config.width + 'px;';
816                 this.totalWidth += config.width;
817             } else {
818                 this.totalWidth += 100; // assume minimum of 100 per column?
819             }
820             */
821             
822             if(typeof(config.cls) != 'undefined'){
823                 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
824             }
825             // this is the bit that doesnt reall work at all...
826             
827             if (this.responsive) {
828                  
829             
830                 ['xs','sm','md','lg'].map(function(size){
831                     
832                     if(typeof(config[size]) == 'undefined'){
833                         return;
834                     }
835                      
836                     if (!config[size]) { // 0 = hidden
837                         // BS 4 '0' is treated as hide that column and below.
838                         c.cls += ' hidden-' + size + ' hidden' + size + '-down';
839                         return;
840                     }
841                     
842                     c.cls += ' col-' + size + '-' + config[size] + (
843                         size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
844                     );
845                     
846                     
847                 });
848             }
849             // at the end?
850             
851             c.html +=' <span class="x-grid-split x-grid-split-' + i + '"></span>';
852             
853             
854             
855             
856             header.cn.push(c)
857         }
858         
859         return header;
860     },
861     
862     renderBody : function()
863     {
864         var body = {
865             tag: 'tbody',
866             cn : [
867                 {
868                     tag: 'tr',
869                     cn : [
870                         {
871                             tag : 'td',
872                             colspan :  this.cm.getColumnCount()
873                         }
874                     ]
875                 }
876             ]
877         };
878         
879         return body;
880     },
881     
882     renderFooter : function()
883     {
884         var footer = {
885             tag: 'tfoot',
886             cn : [
887                 {
888                     tag: 'tr',
889                     cn : [
890                         {
891                             tag : 'td',
892                             colspan :  this.cm.getColumnCount()
893                         }
894                     ]
895                 }
896             ]
897         };
898         
899         return footer;
900     },
901     
902     
903     
904     onLoad : function()
905     {
906 //        Roo.log('ds onload');
907         this.clear();
908         
909         var _this = this;
910         var cm = this.cm;
911         var ds = this.store;
912         
913         Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
914             e.select('i', true).removeClass(['fa-arrow-up', 'fa-arrow-down']);
915             if (_this.store.sortInfo) {
916                     
917                 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
918                     e.select('i', true).addClass(['fa-arrow-up']);
919                 }
920                 
921                 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
922                     e.select('i', true).addClass(['fa-arrow-down']);
923                 }
924             }
925         });
926         
927         var tbody =  this.bodyEl;
928               
929         if(ds.getCount() > 0){
930             ds.data.each(function(d,rowIndex){
931                 var row =  this.renderRow(cm, ds, rowIndex);
932                 
933                 tbody.createChild(row);
934                 
935                 var _this = this;
936                 
937                 if(row.cellObjects.length){
938                     Roo.each(row.cellObjects, function(r){
939                         _this.renderCellObject(r);
940                     })
941                 }
942                 
943             }, this);
944         } else if (this.empty_results.length) {
945             this.el.mask(this.empty_results, 'no-spinner');
946         }
947         
948         var tfoot = this.el.select('tfoot', true).first();
949         
950         if(this.footerShow && this.auto_hide_footer && this.mainFoot){
951             
952             this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
953             
954             var total = this.ds.getTotalCount();
955             
956             if(this.footer.pageSize < total){
957                 this.mainFoot.show();
958             }
959         }
960         
961         Roo.each(this.el.select('tbody td', true).elements, function(e){
962             e.on('mouseover', _this.onMouseover, _this);
963         });
964         
965         Roo.each(this.el.select('tbody td', true).elements, function(e){
966             e.on('mouseout', _this.onMouseout, _this);
967         });
968         this.fireEvent('rowsrendered', this);
969         
970         this.autoSize();
971         
972         this.initCSS(); /// resize cols
973
974         
975     },
976     
977     
978     onUpdate : function(ds,record)
979     {
980         this.refreshRow(record);
981         this.autoSize();
982     },
983     
984     onRemove : function(ds, record, index, isUpdate){
985         if(isUpdate !== true){
986             this.fireEvent("beforerowremoved", this, index, record);
987         }
988         var bt = this.bodyEl.dom;
989         
990         var rows = this.el.select('tbody > tr', true).elements;
991         
992         if(typeof(rows[index]) != 'undefined'){
993             bt.removeChild(rows[index].dom);
994         }
995         
996 //        if(bt.rows[index]){
997 //            bt.removeChild(bt.rows[index]);
998 //        }
999         
1000         if(isUpdate !== true){
1001             //this.stripeRows(index);
1002             //this.syncRowHeights(index, index);
1003             //this.layout();
1004             this.fireEvent("rowremoved", this, index, record);
1005         }
1006     },
1007     
1008     onAdd : function(ds, records, rowIndex)
1009     {
1010         //Roo.log('on Add called');
1011         // - note this does not handle multiple adding very well..
1012         var bt = this.bodyEl.dom;
1013         for (var i =0 ; i < records.length;i++) {
1014             //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
1015             //Roo.log(records[i]);
1016             //Roo.log(this.store.getAt(rowIndex+i));
1017             this.insertRow(this.store, rowIndex + i, false);
1018             return;
1019         }
1020         
1021     },
1022     
1023     
1024     refreshRow : function(record){
1025         var ds = this.store, index;
1026         if(typeof record == 'number'){
1027             index = record;
1028             record = ds.getAt(index);
1029         }else{
1030             index = ds.indexOf(record);
1031             if (index < 0) {
1032                 return; // should not happen - but seems to 
1033             }
1034         }
1035         this.insertRow(ds, index, true);
1036         this.autoSize();
1037         this.onRemove(ds, record, index+1, true);
1038         this.autoSize();
1039         //this.syncRowHeights(index, index);
1040         //this.layout();
1041         this.fireEvent("rowupdated", this, index, record);
1042     },
1043     // private - called by RowSelection
1044     onRowSelect : function(rowIndex){
1045         var row = this.getRowDom(rowIndex);
1046         row.addClass(['bg-info','info']);
1047     },
1048     // private - called by RowSelection
1049     onRowDeselect : function(rowIndex)
1050     {
1051         if (rowIndex < 0) {
1052             return;
1053         }
1054         var row = this.getRowDom(rowIndex);
1055         row.removeClass(['bg-info','info']);
1056     },
1057       /**
1058      * Focuses the specified row.
1059      * @param {Number} row The row index
1060      */
1061     focusRow : function(row)
1062     {
1063         //Roo.log('GridView.focusRow');
1064         var x = this.bodyEl.dom.scrollLeft;
1065         this.focusCell(row, 0, false);
1066         this.bodyEl.dom.scrollLeft = x;
1067
1068     },
1069      /**
1070      * Focuses the specified cell.
1071      * @param {Number} row The row index
1072      * @param {Number} col The column index
1073      * @param {Boolean} hscroll false to disable horizontal scrolling
1074      */
1075     focusCell : function(row, col, hscroll)
1076     {
1077         //Roo.log('GridView.focusCell');
1078         var el = this.ensureVisible(row, col, hscroll);
1079         // not sure what focusEL achives = it's a <a> pos relative 
1080         //this.focusEl.alignTo(el, "tl-tl");
1081         //if(Roo.isGecko){
1082         //    this.focusEl.focus();
1083         //}else{
1084         //    this.focusEl.focus.defer(1, this.focusEl);
1085         //}
1086     },
1087     
1088      /**
1089      * Scrolls the specified cell into view
1090      * @param {Number} row The row index
1091      * @param {Number} col The column index
1092      * @param {Boolean} hscroll false to disable horizontal scrolling
1093      */
1094     ensureVisible : function(row, col, hscroll)
1095     {
1096         //Roo.log('GridView.ensureVisible,' + row + ',' + col);
1097         //return null; //disable for testing.
1098         if(typeof row != "number"){
1099             row = row.rowIndex;
1100         }
1101         if(row < 0 && row >= this.ds.getCount()){
1102             return  null;
1103         }
1104         col = (col !== undefined ? col : 0);
1105         var cm = this.cm;
1106         while(cm.isHidden(col)){
1107             col++;
1108         }
1109
1110         var el = this.getCellDom(row, col);
1111         if(!el){
1112             return null;
1113         }
1114         var c = this.bodyEl.dom;
1115
1116         var ctop = parseInt(el.offsetTop, 10);
1117         var cleft = parseInt(el.offsetLeft, 10);
1118         var cbot = ctop + el.offsetHeight;
1119         var cright = cleft + el.offsetWidth;
1120
1121         //var ch = c.clientHeight - this.mainHd.dom.offsetHeight;
1122         var ch = 0; //?? header is not withing the area?
1123         var stop = parseInt(c.scrollTop, 10);
1124         var sleft = parseInt(c.scrollLeft, 10);
1125         var sbot = stop + ch;
1126         var sright = sleft + c.clientWidth;
1127         /*
1128         Roo.log('GridView.ensureVisible:' +
1129                 ' ctop:' + ctop +
1130                 ' c.clientHeight:' + c.clientHeight +
1131                 ' this.mainHd.dom.offsetHeight:' + this.mainHd.dom.offsetHeight +
1132                 ' stop:' + stop +
1133                 ' cbot:' + cbot +
1134                 ' sbot:' + sbot +
1135                 ' ch:' + ch  
1136                 );
1137         */
1138         if(ctop < stop){
1139             c.scrollTop = ctop;
1140             //Roo.log("set scrolltop to ctop DISABLE?");
1141         }else if(cbot > sbot){
1142             //Roo.log("set scrolltop to cbot-ch");
1143             c.scrollTop = cbot-ch;
1144         }
1145
1146         if(hscroll !== false){
1147             if(cleft < sleft){
1148                 c.scrollLeft = cleft;
1149             }else if(cright > sright){
1150                 c.scrollLeft = cright-c.clientWidth;
1151             }
1152         }
1153
1154         return el;
1155     },
1156     
1157     
1158     insertRow : function(dm, rowIndex, isUpdate){
1159         
1160         if(!isUpdate){
1161             this.fireEvent("beforerowsinserted", this, rowIndex);
1162         }
1163             //var s = this.getScrollState();
1164         var row = this.renderRow(this.cm, this.store, rowIndex);
1165         // insert before rowIndex..
1166         var e = this.bodyEl.createChild(row,this.getRowDom(rowIndex));
1167         
1168         var _this = this;
1169                 
1170         if(row.cellObjects.length){
1171             Roo.each(row.cellObjects, function(r){
1172                 _this.renderCellObject(r);
1173             })
1174         }
1175             
1176         if(!isUpdate){
1177             this.fireEvent("rowsinserted", this, rowIndex);
1178             //this.syncRowHeights(firstRow, lastRow);
1179             //this.stripeRows(firstRow);
1180             //this.layout();
1181         }
1182         
1183     },
1184     
1185     
1186     getRowDom : function(rowIndex)
1187     {
1188         var rows = this.el.select('tbody > tr', true).elements;
1189         
1190         return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
1191         
1192     },
1193     getCellDom : function(rowIndex, colIndex)
1194     {
1195         var row = this.getRowDom(rowIndex);
1196         if (row === false) {
1197             return false;
1198         }
1199         var cols = row.select('td', true).elements;
1200         return (typeof(cols[colIndex]) == 'undefined') ? false : cols[colIndex];
1201         
1202     },
1203     
1204     // returns the object tree for a tr..
1205   
1206     
1207     renderRow : function(cm, ds, rowIndex) 
1208     {
1209         var d = ds.getAt(rowIndex);
1210         
1211         var row = {
1212             tag : 'tr',
1213             cls : 'x-row-' + rowIndex,
1214             cn : []
1215         };
1216             
1217         var cellObjects = [];
1218         
1219         for(var i = 0, len = cm.getColumnCount(); i < len; i++){
1220             var config = cm.config[i];
1221             
1222             var renderer = cm.getRenderer(i);
1223             var value = '';
1224             var id = false;
1225             
1226             if(typeof(renderer) !== 'undefined'){
1227                 value = renderer(d.data[cm.getDataIndex(i)], false, d);
1228             }
1229             // if object are returned, then they are expected to be Roo.bootstrap.Component instances
1230             // and are rendered into the cells after the row is rendered - using the id for the element.
1231             
1232             if(typeof(value) === 'object'){
1233                 id = Roo.id();
1234                 cellObjects.push({
1235                     container : id,
1236                     cfg : value 
1237                 })
1238             }
1239             
1240             var rowcfg = {
1241                 record: d,
1242                 rowIndex : rowIndex,
1243                 colIndex : i,
1244                 rowClass : ''
1245             };
1246
1247             this.fireEvent('rowclass', this, rowcfg);
1248             
1249             var td = {
1250                 tag: 'td',
1251                 // this might end up displaying HTML?
1252                 // this is too messy... - better to only do it on columsn you know are going to be too long
1253                 //tooltip : (typeof(value) === 'object') ? '' : value,
1254                 cls : rowcfg.rowClass + ' x-col-' + i,
1255                 style: '',
1256                 html: (typeof(value) === 'object') ? '' : value
1257             };
1258             
1259             if (id) {
1260                 td.id = id;
1261             }
1262             
1263             if(typeof(config.colspan) != 'undefined'){
1264                 td.colspan = config.colspan;
1265             }
1266             
1267             
1268             
1269             if(typeof(config.align) != 'undefined' && config.align.length){
1270                 td.style += ' text-align:' + config.align + ';';
1271             }
1272             if(typeof(config.valign) != 'undefined' && config.valign.length){
1273                 td.style += ' vertical-align:' + config.valign + ';';
1274             }
1275             /*
1276             if(typeof(config.width) != 'undefined'){
1277                 td.style += ' width:' +  config.width + 'px;';
1278             }
1279             */
1280             
1281             if(typeof(config.cursor) != 'undefined'){
1282                 td.style += ' cursor:' +  config.cursor + ';';
1283             }
1284             
1285             if(typeof(config.cls) != 'undefined'){
1286                 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
1287             }
1288             if (this.responsive) {
1289                 ['xs','sm','md','lg'].map(function(size){
1290                     
1291                     if(typeof(config[size]) == 'undefined'){
1292                         return;
1293                     }
1294                     
1295                     
1296                       
1297                     if (!config[size]) { // 0 = hidden
1298                         // BS 4 '0' is treated as hide that column and below.
1299                         td.cls += ' hidden-' + size + ' hidden' + size + '-down';
1300                         return;
1301                     }
1302                     
1303                     td.cls += ' col-' + size + '-' + config[size] + (
1304                         size == 'xs' ? (' col-' +   config[size] ) : '' // bs4 col-{num} replaces col-xs
1305                     );
1306                      
1307     
1308                 });
1309             }
1310             row.cn.push(td);
1311            
1312         }
1313         
1314         row.cellObjects = cellObjects;
1315         
1316         return row;
1317           
1318     },
1319     
1320     
1321     
1322     onBeforeLoad : function()
1323     {
1324         this.el.unmask(); // if needed.
1325     },
1326      /**
1327      * Remove all rows
1328      */
1329     clear : function()
1330     {
1331         this.el.select('tbody', true).first().dom.innerHTML = '';
1332     },
1333     /**
1334      * Show or hide a row.
1335      * @param {Number} rowIndex to show or hide
1336      * @param {Boolean} state hide
1337      */
1338     setRowVisibility : function(rowIndex, state)
1339     {
1340         var bt = this.bodyEl.dom;
1341         
1342         var rows = this.el.select('tbody > tr', true).elements;
1343         
1344         if(typeof(rows[rowIndex]) == 'undefined'){
1345             return;
1346         }
1347         rows[rowIndex][ state ? 'removeClass' : 'addClass']('d-none');
1348         
1349     },
1350     
1351     
1352     getSelectionModel : function(){
1353         if(!this.selModel){
1354             this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
1355         }
1356         return this.selModel;
1357     },
1358     /*
1359      * Render the Roo.bootstrap object from renderder
1360      */
1361     renderCellObject : function(r)
1362     {
1363         var _this = this;
1364         
1365         r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
1366         
1367         var t = r.cfg.render(r.container);
1368         
1369         if(r.cfg.cn){
1370             Roo.each(r.cfg.cn, function(c){
1371                 var child = {
1372                     container: t.getChildContainer(),
1373                     cfg: c
1374                 };
1375                 _this.renderCellObject(child);
1376             })
1377         }
1378     },
1379     /**
1380      * get the Row Index from a dom element.
1381      * @param {Roo.Element} row The row to look for
1382      * @returns {Number} the row
1383      */
1384     getRowIndex : function(row)
1385     {
1386         var rowIndex = -1;
1387         
1388         Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
1389             if(el != row){
1390                 return;
1391             }
1392             
1393             rowIndex = index;
1394         });
1395         
1396         return rowIndex;
1397     },
1398     /**
1399      * get the header TH element for columnIndex
1400      * @param {Number} columnIndex
1401      * @returns {Roo.Element}
1402      */
1403     getHeaderIndex: function(colIndex)
1404     {
1405         var cols = this.headEl.select('th', true).elements;
1406         return cols[colIndex]; 
1407     },
1408     /**
1409      * get the Column Index from a dom element. (using regex on x-hcol-{colid})
1410      * @param {domElement} cell to look for
1411      * @returns {Number} the column
1412      */
1413     getCellIndex : function(cell)
1414     {
1415         var id = String(cell.className).match(Roo.bootstrap.Table.cellRE);
1416         if(id){
1417             return parseInt(id[1], 10);
1418         }
1419         return 0;
1420     },
1421      /**
1422      * Returns the grid's underlying element = used by panel.Grid
1423      * @return {Element} The element
1424      */
1425     getGridEl : function(){
1426         return this.el;
1427     },
1428      /**
1429      * Forces a resize - used by panel.Grid
1430      * @return {Element} The element
1431      */
1432     autoSize : function()
1433     {
1434         //var ctr = Roo.get(this.container.dom.parentElement);
1435         var ctr = Roo.get(this.el.dom);
1436         
1437         var thd = this.getGridEl().select('thead',true).first();
1438         var tbd = this.getGridEl().select('tbody', true).first();
1439         var tfd = this.getGridEl().select('tfoot', true).first();
1440         
1441         var cw = ctr.getWidth();
1442         this.getGridEl().select('tfoot tr, tfoot  td',true).setWidth(cw);
1443         
1444         if (tbd) {
1445             
1446             tbd.setWidth(ctr.getWidth());
1447             // if the body has a max height - and then scrolls - we should perhaps set up the height here
1448             // this needs fixing for various usage - currently only hydra job advers I think..
1449             //tdb.setHeight(
1450             //        ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
1451             //); 
1452             var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
1453             cw -= barsize;
1454         }
1455         cw = Math.max(cw, this.totalWidth);
1456         this.getGridEl().select('tbody tr',true).setWidth(cw);
1457         this.initCSS();
1458         
1459         // resize 'expandable coloumn?
1460         
1461         return; // we doe not have a view in this design..
1462         
1463     },
1464     onBodyScroll: function()
1465     {
1466         //Roo.log("body scrolled');" + this.bodyEl.dom.scrollLeft);
1467         if(this.headEl){
1468             this.headEl.setStyle({
1469                 'position' : 'relative',
1470                 'left': (-1* this.bodyEl.dom.scrollLeft) + 'px'
1471             });
1472         }
1473         
1474         if(this.lazyLoad){
1475             
1476             var scrollHeight = this.bodyEl.dom.scrollHeight;
1477             
1478             var scrollTop = Math.ceil(this.bodyEl.getScroll().top);
1479             
1480             var height = this.bodyEl.getHeight();
1481             
1482             if(scrollHeight - height == scrollTop) {
1483                 
1484                 var total = this.ds.getTotalCount();
1485                 
1486                 if(this.footer.cursor + this.footer.pageSize < total){
1487                     
1488                     this.footer.ds.load({
1489                         params : {
1490                             start : this.footer.cursor + this.footer.pageSize,
1491                             limit : this.footer.pageSize
1492                         },
1493                         add : true
1494                     });
1495                 }
1496             }
1497             
1498         }
1499     },
1500     onColumnSplitterMoved : function(i, diff)
1501     {
1502         this.userResized = true;
1503         
1504         var cm = this.colModel;
1505         
1506         var w = this.getHeaderIndex(i).getWidth() + diff;
1507         
1508         
1509         cm.setColumnWidth(i, w, true);
1510         this.initCSS();
1511         //var cid = cm.getColumnId(i); << not used in this version?
1512        /* Roo.log(['#' + this.id + ' .x-col-' + i, "width", w + "px"]);
1513         
1514         this.CSS.updateRule( '#' + this.id + ' .x-col-' + i, "width", w + "px");
1515         this.CSS.updateRule('#' + this.id + ' .x-hcol-' + i, "width", w + "px");
1516         this.CSS.updateRule('#' + this.id + ' .x-grid-split-' + i, "left", w + "px");
1517 */
1518         //this.updateSplitters();
1519         //this.layout(); << ??
1520         this.fireEvent("columnresize", i, w);
1521     },
1522     onHeaderChange : function()
1523     {
1524         var header = this.renderHeader();
1525         var table = this.el.select('table', true).first();
1526         
1527         this.headEl.remove();
1528         this.headEl = table.createChild(header, this.bodyEl, false);
1529         
1530         Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
1531             e.on('click', this.sort, this);
1532         }, this);
1533         
1534         if(this.enableColumnResize !== false && Roo.grid.SplitDragZone){
1535             new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
1536         }
1537         
1538     },
1539     
1540     onHiddenChange : function(colModel, colIndex, hidden)
1541     {
1542         /*
1543         this.cm.setHidden()
1544         var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
1545         var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
1546         
1547         this.CSS.updateRule(thSelector, "display", "");
1548         this.CSS.updateRule(tdSelector, "display", "");
1549         
1550         if(hidden){
1551             this.CSS.updateRule(thSelector, "display", "none");
1552             this.CSS.updateRule(tdSelector, "display", "none");
1553         }
1554         */
1555         // onload calls initCSS()
1556         this.onHeaderChange();
1557         this.onLoad();
1558     },
1559     
1560     setColumnWidth: function(col_index, width)
1561     {
1562         // width = "md-2 xs-2..."
1563         if(!this.colModel.config[col_index]) {
1564             return;
1565         }
1566         
1567         var w = width.split(" ");
1568         
1569         var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
1570         
1571         var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
1572         
1573         
1574         for(var j = 0; j < w.length; j++) {
1575             
1576             if(!w[j]) {
1577                 continue;
1578             }
1579             
1580             var size_cls = w[j].split("-");
1581             
1582             if(!Number.isInteger(size_cls[1] * 1)) {
1583                 continue;
1584             }
1585             
1586             if(!this.colModel.config[col_index][size_cls[0]]) {
1587                 continue;
1588             }
1589             
1590             if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
1591                 continue;
1592             }
1593             
1594             h_row[0].classList.replace(
1595                 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
1596                 "col-"+size_cls[0]+"-"+size_cls[1]
1597             );
1598             
1599             for(var i = 0; i < rows.length; i++) {
1600                 
1601                 var size_cls = w[j].split("-");
1602                 
1603                 if(!Number.isInteger(size_cls[1] * 1)) {
1604                     continue;
1605                 }
1606                 
1607                 if(!this.colModel.config[col_index][size_cls[0]]) {
1608                     continue;
1609                 }
1610                 
1611                 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
1612                     continue;
1613                 }
1614                 
1615                 rows[i].classList.replace(
1616                     "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
1617                     "col-"+size_cls[0]+"-"+size_cls[1]
1618                 );
1619             }
1620             
1621             this.colModel.config[col_index][size_cls[0]] = size_cls[1];
1622         }
1623     }
1624 });
1625
1626 // currently only used to find the split on drag.. 
1627 Roo.bootstrap.Table.cellRE = /(?:.*?)x-grid-(?:hd|cell|split)-([\d]+)(?:.*?)/;
1628
1629 /**
1630  * @depricated
1631 */
1632 Roo.bootstrap.Table.AbstractSelectionModel = Roo.grid.AbstractSelectionModel;
1633 Roo.bootstrap.Table.RowSelectionModel = Roo.grid.RowSelectionModel;