saved number of columns in config.columns

This commit is contained in:
Mottie 2013-01-26 08:50:15 -06:00
parent 2c8c6fbbe2
commit be638d8db5

View File

@ -170,7 +170,8 @@
function buildParserCache(table) { function buildParserCache(table) {
var c = table.config, var c = table.config,
tb = c.$tbodies, // update table bodies in case we start with an empty table
tb = c.$tbodies = c.$table.children('tbody:not(.' + c.cssInfoBlock + ')'),
rows, list, l, i, h, ch, p, parsersDebug = ""; rows, list, l, i, h, ch, p, parsersDebug = "";
if ( tb.length === 0) { if ( tb.length === 0) {
return c.debug ? log('*Empty table!* Not building a parser cache') : ''; return c.debug ? log('*Empty table!* Not building a parser cache') : '';
@ -322,6 +323,7 @@
function computeThIndexes(t) { function computeThIndexes(t) {
var matrix = [], var matrix = [],
lookup = {}, lookup = {},
cols = 0, // determine the number of columns
trs = $(t).find('thead:eq(0), tfoot').children('tr'), // children tr in tfoot - see issue #196 trs = $(t).find('thead:eq(0), tfoot').children('tr'), // children tr in tfoot - see issue #196
i, j, k, l, c, cells, rowIndex, cellId, rowSpan, colSpan, firstAvailCol, matrixrow; i, j, k, l, c, cells, rowIndex, cellId, rowSpan, colSpan, firstAvailCol, matrixrow;
for (i = 0; i < trs.length; i++) { for (i = 0; i < trs.length; i++) {
@ -343,6 +345,7 @@
} }
} }
lookup[cellId] = firstAvailCol; lookup[cellId] = firstAvailCol;
cols = Math.max(firstAvailCol, cols);
// add data-column // add data-column
$(c).attr({ 'data-column' : firstAvailCol }); // 'data-row' : rowIndex $(c).attr({ 'data-column' : firstAvailCol }); // 'data-row' : rowIndex
for (k = rowIndex; k < rowIndex + rowSpan; k++) { for (k = rowIndex; k < rowIndex + rowSpan; k++) {
@ -356,6 +359,7 @@
} }
} }
} }
t.config.columns = cols; // may not be accurate if # header columns !== # tbody columns
return lookup; return lookup;
} }
@ -448,7 +452,7 @@
var $c, c = table.config, var $c, c = table.config,
$cg = $('<colgroup>'), $cg = $('<colgroup>'),
$cgo = c.$table.find('colgroup'), $cgo = c.$table.find('colgroup'),
n = c.parsers.length, n = c.columns.length,
overallWidth = c.$table.width(); overallWidth = c.$table.width();
$("tr:first td", table.tBodies[0]).each(function(i) { $("tr:first td", table.tBodies[0]).each(function(i) {
$c = $('<col>'); $c = $('<col>');
@ -575,6 +579,9 @@
c.$tbodies = $this.children('tbody:not(.' + c.cssInfoBlock + ')'); c.$tbodies = $this.children('tbody:not(.' + c.cssInfoBlock + ')');
// build headers // build headers
c.$headers = buildHeaders($t0); c.$headers = buildHeaders($t0);
// fixate columns if the users supplies the fixedWidth option
// do this after theme has been applied
fixColumnWidth($t0);
// try to auto detect column type, and store in tables config // try to auto detect column type, and store in tables config
c.parsers = buildParserCache($t0); c.parsers = buildParserCache($t0);
// build the cache for the tbody cells // build the cache for the tbody cells
@ -816,10 +823,6 @@
ts.applyWidget($t0); ts.applyWidget($t0);
} }
// fixate columns if the users supplies the fixedWidth option
// do this after theme has been applied
fixColumnWidth($t0);
// show processesing icon // show processesing icon
if (c.showProcessing) { if (c.showProcessing) {
$this $this