9 * @class Roo.bootstrap.Table
10 * @extends Roo.bootstrap.Component
11 * Bootstrap Table class
12 * @cfg {String} cls table class
13 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
14 * @cfg {String} bgcolor Specifies the background color for a table
15 * @cfg {Number} border Specifies whether the table cells should have borders or not
16 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
17 * @cfg {Number} cellspacing Specifies the space between cells
18 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
19 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
20 * @cfg {String} sortable Specifies that the table should be sortable
21 * @cfg {String} summary Specifies a summary of the content of a table
22 * @cfg {Number} width Specifies the width of a table
23 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
25 * @cfg {boolean} striped Should the rows be alternative striped
26 * @cfg {boolean} bordered Add borders to the table
27 * @cfg {boolean} hover Add hover highlighting
28 * @cfg {boolean} condensed Format condensed
29 * @cfg {boolean} responsive Format condensed
30 * @cfg {Boolean} loadMask (true|false) default false
31 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
32 * @cfg {Boolean} headerShow (true|false) generate thead, default true
33 * @cfg {Boolean} rowSelection (true|false) default false
34 * @cfg {Boolean} cellSelection (true|false) default false
35 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
36 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
37 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
38 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
43 * @param {Object} config The config object
46 Roo.bootstrap.Table = function(config){
47 Roo.bootstrap.Table.superclass.constructor.call(this, config);
52 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
53 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
54 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
55 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
57 this.sm = this.sm || {xtype: 'RowSelectionModel'};
60 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
61 this.sm = this.selModel;
62 this.sm.xmodule = this.xmodule || false;
65 if (this.cm && typeof(this.cm.config) == 'undefined') {
66 this.colModel = new Roo.grid.ColumnModel(this.cm);
67 this.cm = this.colModel;
68 this.cm.xmodule = this.xmodule || false;
71 this.store= Roo.factory(this.store, Roo.data);
73 this.ds.xmodule = this.xmodule || false;
76 if (this.footer && this.store) {
77 this.footer.dataSource = this.ds;
78 this.footer = Roo.factory(this.footer);
85 * Fires when a cell is clicked
86 * @param {Roo.bootstrap.Table} this
87 * @param {Roo.Element} el
88 * @param {Number} rowIndex
89 * @param {Number} columnIndex
90 * @param {Roo.EventObject} e
95 * Fires when a cell is double clicked
96 * @param {Roo.bootstrap.Table} this
97 * @param {Roo.Element} el
98 * @param {Number} rowIndex
99 * @param {Number} columnIndex
100 * @param {Roo.EventObject} e
102 "celldblclick" : true,
105 * Fires when a row is clicked
106 * @param {Roo.bootstrap.Table} this
107 * @param {Roo.Element} el
108 * @param {Number} rowIndex
109 * @param {Roo.EventObject} e
114 * Fires when a row is double clicked
115 * @param {Roo.bootstrap.Table} this
116 * @param {Roo.Element} el
117 * @param {Number} rowIndex
118 * @param {Roo.EventObject} e
120 "rowdblclick" : true,
123 * Fires when a mouseover occur
124 * @param {Roo.bootstrap.Table} this
125 * @param {Roo.Element} el
126 * @param {Number} rowIndex
127 * @param {Number} columnIndex
128 * @param {Roo.EventObject} e
133 * Fires when a mouseout occur
134 * @param {Roo.bootstrap.Table} this
135 * @param {Roo.Element} el
136 * @param {Number} rowIndex
137 * @param {Number} columnIndex
138 * @param {Roo.EventObject} e
143 * Fires when a row is rendered, so you can change add a style to it.
144 * @param {Roo.bootstrap.Table} this
145 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
149 * @event rowsrendered
150 * Fires when all the rows have been rendered
151 * @param {Roo.bootstrap.Table} this
153 'rowsrendered' : true,
156 * The raw contextmenu event for the entire grid.
157 * @param {Roo.EventObject} e
159 "contextmenu" : true,
161 * @event rowcontextmenu
162 * Fires when a row is right clicked
163 * @param {Roo.bootstrap.Table} this
164 * @param {Number} rowIndex
165 * @param {Roo.EventObject} e
167 "rowcontextmenu" : true,
169 * @event cellcontextmenu
170 * Fires when a cell is right clicked
171 * @param {Roo.bootstrap.Table} this
172 * @param {Number} rowIndex
173 * @param {Number} cellIndex
174 * @param {Roo.EventObject} e
176 "cellcontextmenu" : true,
178 * @event headercontextmenu
179 * Fires when a header is right clicked
180 * @param {Roo.bootstrap.Table} this
181 * @param {Number} columnIndex
182 * @param {Roo.EventObject} e
184 "headercontextmenu" : true
188 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
214 rowSelection : false,
215 cellSelection : false,
218 // Roo.Element - the tbody
220 // Roo.Element - thead element
223 container: false, // used by gridpanel...
229 auto_hide_footer : false,
231 getAutoCreate : function()
233 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
240 if (this.scrollBody) {
241 cfg.cls += ' table-body-fixed';
244 cfg.cls += ' table-striped';
248 cfg.cls += ' table-hover';
251 cfg.cls += ' table-bordered';
253 if (this.condensed) {
254 cfg.cls += ' table-condensed';
256 if (this.responsive) {
257 cfg.cls += ' table-responsive';
261 cfg.cls+= ' ' +this.cls;
264 // this lot should be simplifed...
277 ].forEach(function(k) {
285 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
288 if(this.store || this.cm){
290 cfg.cn.push(this.renderHeader());
293 cfg.cn.push(this.renderBody());
296 cfg.cn.push(this.renderFooter());
298 // where does this come from?
299 //cfg.cls+= ' TableGrid';
302 return { cn : [ cfg ] };
305 initEvents : function()
307 if(!this.store || !this.cm){
311 this.selModel.initEvents();
315 //Roo.log('initEvents with ds!!!!');
317 this.mainBody = this.el.select('tbody', true).first();
318 this.mainHead = this.el.select('thead', true).first();
319 this.mainFoot = this.el.select('tfoot', true).first();
324 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
325 e.on('click', this.sort, this);
328 this.mainBody.on("click", this.onClick, this);
329 this.mainBody.on("dblclick", this.onDblClick, this);
331 // why is this done????? = it breaks dialogs??
332 //this.parent().el.setStyle('position', 'relative');
336 this.footer.parentId = this.id;
337 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
340 this.el.select('tfoot tr td').first().addClass('hide');
345 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
348 this.store.on('load', this.onLoad, this);
349 this.store.on('beforeload', this.onBeforeLoad, this);
350 this.store.on('update', this.onUpdate, this);
351 this.store.on('add', this.onAdd, this);
352 this.store.on("clear", this.clear, this);
354 this.el.on("contextmenu", this.onContextMenu, this);
356 this.mainBody.on('scroll', this.onBodyScroll, this);
358 this.cm.on("headerchange", this.onHeaderChange, this);
360 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
364 onContextMenu : function(e, t)
366 this.processEvent("contextmenu", e);
369 processEvent : function(name, e)
371 if (name != 'touchstart' ) {
372 this.fireEvent(name, e);
375 var t = e.getTarget();
377 var cell = Roo.get(t);
383 if(cell.findParent('tfoot', false, true)){
387 if(cell.findParent('thead', false, true)){
389 if(e.getTarget().nodeName.toLowerCase() != 'th'){
390 cell = Roo.get(t).findParent('th', false, true);
392 Roo.log("failed to find th in thead?");
393 Roo.log(e.getTarget());
398 var cellIndex = cell.dom.cellIndex;
400 var ename = name == 'touchstart' ? 'click' : name;
401 this.fireEvent("header" + ename, this, cellIndex, e);
406 if(e.getTarget().nodeName.toLowerCase() != 'td'){
407 cell = Roo.get(t).findParent('td', false, true);
409 Roo.log("failed to find th in tbody?");
410 Roo.log(e.getTarget());
415 var row = cell.findParent('tr', false, true);
416 var cellIndex = cell.dom.cellIndex;
417 var rowIndex = row.dom.rowIndex - 1;
421 this.fireEvent("row" + name, this, rowIndex, e);
425 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
431 onMouseover : function(e, el)
433 var cell = Roo.get(el);
439 if(e.getTarget().nodeName.toLowerCase() != 'td'){
440 cell = cell.findParent('td', false, true);
443 var row = cell.findParent('tr', false, true);
444 var cellIndex = cell.dom.cellIndex;
445 var rowIndex = row.dom.rowIndex - 1; // start from 0
447 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
451 onMouseout : function(e, el)
453 var cell = Roo.get(el);
459 if(e.getTarget().nodeName.toLowerCase() != 'td'){
460 cell = cell.findParent('td', false, true);
463 var row = cell.findParent('tr', false, true);
464 var cellIndex = cell.dom.cellIndex;
465 var rowIndex = row.dom.rowIndex - 1; // start from 0
467 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
471 onClick : function(e, el)
473 var cell = Roo.get(el);
475 if(!cell || (!this.cellSelection && !this.rowSelection)){
479 if(e.getTarget().nodeName.toLowerCase() != 'td'){
480 cell = cell.findParent('td', false, true);
483 if(!cell || typeof(cell) == 'undefined'){
487 var row = cell.findParent('tr', false, true);
489 if(!row || typeof(row) == 'undefined'){
493 var cellIndex = cell.dom.cellIndex;
494 var rowIndex = this.getRowIndex(row);
496 // why??? - should these not be based on SelectionModel?
497 if(this.cellSelection){
498 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
501 if(this.rowSelection){
502 this.fireEvent('rowclick', this, row, rowIndex, e);
508 onDblClick : function(e,el)
510 var cell = Roo.get(el);
512 if(!cell || (!this.cellSelection && !this.rowSelection)){
516 if(e.getTarget().nodeName.toLowerCase() != 'td'){
517 cell = cell.findParent('td', false, true);
520 if(!cell || typeof(cell) == 'undefined'){
524 var row = cell.findParent('tr', false, true);
526 if(!row || typeof(row) == 'undefined'){
530 var cellIndex = cell.dom.cellIndex;
531 var rowIndex = this.getRowIndex(row);
533 if(this.cellSelection){
534 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
537 if(this.rowSelection){
538 this.fireEvent('rowdblclick', this, row, rowIndex, e);
542 sort : function(e,el)
544 var col = Roo.get(el);
546 if(!col.hasClass('sortable')){
550 var sort = col.attr('sort');
553 if(col.select('i', true).first().hasClass('fa-arrow-up')){
557 this.store.sortInfo = {field : sort, direction : dir};
560 Roo.log("calling footer first");
561 this.footer.onClick('first');
564 this.store.load({ params : { start : 0 } });
568 renderHeader : function()
578 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
580 var config = cm.config[i];
587 html: cm.getColumnHeader(i)
590 var tooltip = cm.getColumnTooltip(i);
598 if(typeof(config.sortable) != 'undefined' && config.sortable){
600 c.html = '<i class="fa"></i>' + c.html;
603 // could use BS4 hidden-..-down
605 if(typeof(config.lgHeader) != 'undefined'){
606 hh += '<span class="hidden-xs hidden-sm hidden-md ">' + config.lgHeader + '</span>';
609 if(typeof(config.mdHeader) != 'undefined'){
610 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
613 if(typeof(config.smHeader) != 'undefined'){
614 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
617 if(typeof(config.xsHeader) != 'undefined'){
618 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
625 if(typeof(config.tooltip) != 'undefined'){
626 c.tooltip = config.tooltip;
629 if(typeof(config.colspan) != 'undefined'){
630 c.colspan = config.colspan;
633 if(typeof(config.hidden) != 'undefined' && config.hidden){
634 c.style += ' display:none;';
637 if(typeof(config.dataIndex) != 'undefined'){
638 c.sort = config.dataIndex;
643 if(typeof(config.align) != 'undefined' && config.align.length){
644 c.style += ' text-align:' + config.align + ';';
647 if(typeof(config.width) != 'undefined'){
648 c.style += ' width:' + config.width + 'px;';
649 this.totalWidth += config.width;
651 this.totalWidth += 100; // assume minimum of 100 per column?
654 if(typeof(config.cls) != 'undefined'){
655 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
658 ['xs','sm','md','lg'].map(function(size){
660 if(typeof(config[size]) == 'undefined'){
664 if (!config[size]) { // 0 = hidden
665 // BS 4 '0' is treated as hide that column and below.
666 c.cls += ' hidden-' + size + ' hidden' + size + '-down';
670 c.cls += ' col-' + size + '-' + config[size] + (
671 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
683 renderBody : function()
693 colspan : this.cm.getColumnCount()
703 renderFooter : function()
713 colspan : this.cm.getColumnCount()
727 // Roo.log('ds onload');
734 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
735 e.select('i', true).removeClass(['fa-arrow-up', 'fa-arrow-down']);
736 if (_this.store.sortInfo) {
738 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
739 e.select('i', true).addClass(['fa-arrow-up']);
742 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
743 e.select('i', true).addClass(['fa-arrow-down']);
748 var tbody = this.mainBody;
750 if(ds.getCount() > 0){
751 ds.data.each(function(d,rowIndex){
752 var row = this.renderRow(cm, ds, rowIndex);
754 tbody.createChild(row);
758 if(row.cellObjects.length){
759 Roo.each(row.cellObjects, function(r){
760 _this.renderCellObject(r);
767 var tfoot = this.el.select('tfoot', true).first();
769 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
771 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
773 var total = this.ds.getTotalCount();
775 if(this.footer.pageSize < total){
776 this.mainFoot.show();
780 Roo.each(this.el.select('tbody td', true).elements, function(e){
781 e.on('mouseover', _this.onMouseover, _this);
784 Roo.each(this.el.select('tbody td', true).elements, function(e){
785 e.on('mouseout', _this.onMouseout, _this);
787 this.fireEvent('rowsrendered', this);
793 onUpdate : function(ds,record)
795 this.refreshRow(record);
799 onRemove : function(ds, record, index, isUpdate){
800 if(isUpdate !== true){
801 this.fireEvent("beforerowremoved", this, index, record);
803 var bt = this.mainBody.dom;
805 var rows = this.el.select('tbody > tr', true).elements;
807 if(typeof(rows[index]) != 'undefined'){
808 bt.removeChild(rows[index].dom);
811 // if(bt.rows[index]){
812 // bt.removeChild(bt.rows[index]);
815 if(isUpdate !== true){
816 //this.stripeRows(index);
817 //this.syncRowHeights(index, index);
819 this.fireEvent("rowremoved", this, index, record);
823 onAdd : function(ds, records, rowIndex)
825 //Roo.log('on Add called');
826 // - note this does not handle multiple adding very well..
827 var bt = this.mainBody.dom;
828 for (var i =0 ; i < records.length;i++) {
829 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
830 //Roo.log(records[i]);
831 //Roo.log(this.store.getAt(rowIndex+i));
832 this.insertRow(this.store, rowIndex + i, false);
839 refreshRow : function(record){
840 var ds = this.store, index;
841 if(typeof record == 'number'){
843 record = ds.getAt(index);
845 index = ds.indexOf(record);
847 return; // should not happen - but seems to
850 this.insertRow(ds, index, true);
852 this.onRemove(ds, record, index+1, true);
854 //this.syncRowHeights(index, index);
856 this.fireEvent("rowupdated", this, index, record);
859 insertRow : function(dm, rowIndex, isUpdate){
862 this.fireEvent("beforerowsinserted", this, rowIndex);
864 //var s = this.getScrollState();
865 var row = this.renderRow(this.cm, this.store, rowIndex);
866 // insert before rowIndex..
867 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
871 if(row.cellObjects.length){
872 Roo.each(row.cellObjects, function(r){
873 _this.renderCellObject(r);
878 this.fireEvent("rowsinserted", this, rowIndex);
879 //this.syncRowHeights(firstRow, lastRow);
880 //this.stripeRows(firstRow);
887 getRowDom : function(rowIndex)
889 var rows = this.el.select('tbody > tr', true).elements;
891 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
894 // returns the object tree for a tr..
897 renderRow : function(cm, ds, rowIndex)
899 var d = ds.getAt(rowIndex);
903 cls : 'x-row-' + rowIndex,
907 var cellObjects = [];
909 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
910 var config = cm.config[i];
912 var renderer = cm.getRenderer(i);
916 if(typeof(renderer) !== 'undefined'){
917 value = renderer(d.data[cm.getDataIndex(i)], false, d);
919 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
920 // and are rendered into the cells after the row is rendered - using the id for the element.
922 if(typeof(value) === 'object'){
937 this.fireEvent('rowclass', this, rowcfg);
941 // this might end up displaying HTML?
942 // this is too messy... - better to only do it on columsn you know are going to be too long
943 //tooltip : (typeof(value) === 'object') ? '' : value,
944 cls : rowcfg.rowClass + ' x-col-' + i,
946 html: (typeof(value) === 'object') ? '' : value
953 if(typeof(config.colspan) != 'undefined'){
954 td.colspan = config.colspan;
957 if(typeof(config.hidden) != 'undefined' && config.hidden){
958 td.style += ' display:none;';
961 if(typeof(config.align) != 'undefined' && config.align.length){
962 td.style += ' text-align:' + config.align + ';';
964 if(typeof(config.valign) != 'undefined' && config.valign.length){
965 td.style += ' vertical-align:' + config.valign + ';';
968 if(typeof(config.width) != 'undefined'){
969 td.style += ' width:' + config.width + 'px;';
972 if(typeof(config.cursor) != 'undefined'){
973 td.style += ' cursor:' + config.cursor + ';';
976 if(typeof(config.cls) != 'undefined'){
977 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
980 ['xs','sm','md','lg'].map(function(size){
982 if(typeof(config[size]) == 'undefined'){
988 if (!config[size]) { // 0 = hidden
989 // BS 4 '0' is treated as hide that column and below.
990 td.cls += ' hidden-' + size + ' hidden' + size + '-down';
994 td.cls += ' col-' + size + '-' + config[size] + (
995 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
1005 row.cellObjects = cellObjects;
1013 onBeforeLoad : function()
1022 this.el.select('tbody', true).first().dom.innerHTML = '';
1025 * Show or hide a row.
1026 * @param {Number} rowIndex to show or hide
1027 * @param {Boolean} state hide
1029 setRowVisibility : function(rowIndex, state)
1031 var bt = this.mainBody.dom;
1033 var rows = this.el.select('tbody > tr', true).elements;
1035 if(typeof(rows[rowIndex]) == 'undefined'){
1038 rows[rowIndex].dom.style.display = state ? '' : 'none';
1042 getSelectionModel : function(){
1044 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
1046 return this.selModel;
1049 * Render the Roo.bootstrap object from renderder
1051 renderCellObject : function(r)
1055 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
1057 var t = r.cfg.render(r.container);
1060 Roo.each(r.cfg.cn, function(c){
1062 container: t.getChildContainer(),
1065 _this.renderCellObject(child);
1070 getRowIndex : function(row)
1074 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
1085 * Returns the grid's underlying element = used by panel.Grid
1086 * @return {Element} The element
1088 getGridEl : function(){
1092 * Forces a resize - used by panel.Grid
1093 * @return {Element} The element
1095 autoSize : function()
1097 //var ctr = Roo.get(this.container.dom.parentElement);
1098 var ctr = Roo.get(this.el.dom);
1100 var thd = this.getGridEl().select('thead',true).first();
1101 var tbd = this.getGridEl().select('tbody', true).first();
1102 var tfd = this.getGridEl().select('tfoot', true).first();
1104 var cw = ctr.getWidth();
1105 this.getGridEl().select('tfoot tr, tfoot td',true).setWidth(cw);
1109 tbd.setWidth(ctr.getWidth());
1110 // if the body has a max height - and then scrolls - we should perhaps set up the height here
1111 // this needs fixing for various usage - currently only hydra job advers I think..
1113 // ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
1115 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
1118 cw = Math.max(cw, this.totalWidth);
1119 this.getGridEl().select('tbody tr',true).setWidth(cw);
1121 // resize 'expandable coloumn?
1123 return; // we doe not have a view in this design..
1126 onBodyScroll: function()
1128 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
1130 this.mainHead.setStyle({
1131 'position' : 'relative',
1132 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
1138 var scrollHeight = this.mainBody.dom.scrollHeight;
1140 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
1142 var height = this.mainBody.getHeight();
1144 if(scrollHeight - height == scrollTop) {
1146 var total = this.ds.getTotalCount();
1148 if(this.footer.cursor + this.footer.pageSize < total){
1150 this.footer.ds.load({
1152 start : this.footer.cursor + this.footer.pageSize,
1153 limit : this.footer.pageSize
1163 onHeaderChange : function()
1165 var header = this.renderHeader();
1166 var table = this.el.select('table', true).first();
1168 this.mainHead.remove();
1169 this.mainHead = table.createChild(header, this.mainBody, false);
1171 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
1172 e.on('click', this.sort, this);
1178 onHiddenChange : function(colModel, colIndex, hidden)
1180 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
1181 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
1183 this.CSS.updateRule(thSelector, "display", "");
1184 this.CSS.updateRule(tdSelector, "display", "");
1187 this.CSS.updateRule(thSelector, "display", "none");
1188 this.CSS.updateRule(tdSelector, "display", "none");
1191 this.onHeaderChange();
1195 setColumnWidth: function(col_index, width)
1197 // width = "md-2 xs-2..."
1198 if(!this.colModel.config[col_index]) {
1202 var w = width.split(" ");
1204 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
1206 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
1209 for(var j = 0; j < w.length; j++) {
1215 var size_cls = w[j].split("-");
1217 if(!Number.isInteger(size_cls[1] * 1)) {
1221 if(!this.colModel.config[col_index][size_cls[0]]) {
1225 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
1229 h_row[0].classList.replace(
1230 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
1231 "col-"+size_cls[0]+"-"+size_cls[1]
1234 for(var i = 0; i < rows.length; i++) {
1236 var size_cls = w[j].split("-");
1238 if(!Number.isInteger(size_cls[1] * 1)) {
1242 if(!this.colModel.config[col_index][size_cls[0]]) {
1246 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
1250 rows[i].classList.replace(
1251 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
1252 "col-"+size_cls[0]+"-"+size_cls[1]
1256 this.colModel.config[col_index][size_cls[0]] = size_cls[1];