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