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