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