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