Merge pull request #822 from prijutme4ty/fix_multiple_tbodies_cache

Fix multiple tbodies cache
This commit is contained in:
Justin F. Hallett 2015-02-20 09:51:20 -07:00
commit 62cda37d60
8 changed files with 124 additions and 134 deletions

View File

@ -135,18 +135,15 @@
}, },
calcFilters = function(table, p) { calcFilters = function(table, p) {
var tbodyIndex, var c = table.config,
c = table.config,
hasFilters = c.$table.hasClass('hasFilters'); hasFilters = c.$table.hasClass('hasFilters');
if (hasFilters && !p.ajaxUrl) { if (hasFilters && !p.ajaxUrl) {
if ($.isEmptyObject(c.cache)) { if ($.isEmptyObject(c.cache)) {
// delayInit: true so nothing is in the cache // delayInit: true so nothing is in the cache
p.filteredRows = p.totalRows = c.$tbodies.eq(0).children('tr').not( p.countChildRows ? '' : '.' + c.cssChildRow ).length; p.filteredRows = p.totalRows = c.$tbodies.eq(0).children('tr').not( p.countChildRows ? '' : '.' + c.cssChildRow ).length;
} else { } else {
// just in case the pager tbody isn't the first tbody
tbodyIndex = c.$table.children('tbody').index( c.$tbodies.eq(0) );
p.filteredRows = 0; p.filteredRows = 0;
$.each(c.cache[tbodyIndex].normalized, function(i, el) { $.each(c.cache[0].normalized, function(i, el) {
p.filteredRows += p.regexRows.test(el[c.columns].$row[0].className) ? 0 : 1; p.filteredRows += p.regexRows.test(el[c.columns].$row[0].className) ? 0 : 1;
}); });
} }
@ -659,8 +656,7 @@
c.$table.trigger('updateCache', [ function(){ c.$table.trigger('updateCache', [ function(){
var i, var i,
rows = [], rows = [],
tbodyIndex = c.$table.children('tbody').index( c.$tbodies.eq(0) ), n = table.config.cache[0].normalized;
n = table.config.cache[tbodyIndex].normalized;
p.totalRows = n.length; p.totalRows = n.length;
for (i = 0; i < p.totalRows; i++) { for (i = 0; i < p.totalRows; i++) {
rows.push(n[i][c.columns].$row); rows.push(n[i][c.columns].$row);

View File

@ -5325,12 +5325,12 @@ var config = $('#mytable').data('tablesorter');
<tr id="variable-cache"> <tr id="variable-cache">
<td><a href="#" class="permalink">config.cache</a></td> <td><a href="#" class="permalink">config.cache</a></td>
<td>Object</td> <td>Object</td>
<td>Internal list of table contents (<span class="version">v2.0.18</span>; <span class="version updated">v2.19.1</span> ) <td>Internal list of table contents (<span class="version">v2.0.18</span>; <span class="version updated">v2.19.2</span> )
<div class="collapsible"> <div class="collapsible">
<br> <br>
This object contains the following:<br> This object contains the following:<br>
<ul> <ul>
<li>tbody index <li>tbody index (non-info block only, numeration is the same as for <a href="#variable-tbodies"><code>config.$tbodies</code></a> <span class="version updated">v2.19.2</span>)
<ul> <ul>
<li><code>colMax</code> <li><code>colMax</code>
<ul> <ul>
@ -5796,7 +5796,6 @@ var p = $('#mytable').data('tablesorter').pager;
For example, if you want to get the parsed values for the rows currently displayed within the pager, use the <code>table.config.pager.cacheIndex</code> variable as follows: For example, if you want to get the parsed values for the rows currently displayed within the pager, use the <code>table.config.pager.cacheIndex</code> variable as follows:
<pre class="prettyprint lang-js">var c = $('table')[0].config, <pre class="prettyprint lang-js">var c = $('table')[0].config,
p = c.pager, p = c.pager,
// the cache may not have a zero index if there are any "info-only" tbodies above the main tbody
cache = c.cache[0].normalized, cache = c.cache[0].normalized,
cachedValues = []; cachedValues = [];
$.each( p.cacheIndex, function(i, v) { $.each( p.cacheIndex, function(i, v) {

View File

@ -136,7 +136,6 @@
headerRow : 'tablesorter-headerRow', headerRow : 'tablesorter-headerRow',
headerIn : 'tablesorter-header-inner', headerIn : 'tablesorter-header-inner',
icon : 'tablesorter-icon', icon : 'tablesorter-icon',
info : 'tablesorter-infoOnly',
processing : 'tablesorter-processing', processing : 'tablesorter-processing',
sortAsc : 'tablesorter-headerAsc', sortAsc : 'tablesorter-headerAsc',
sortDesc : 'tablesorter-headerDesc', sortDesc : 'tablesorter-headerDesc',
@ -295,10 +294,10 @@
/* utils */ /* utils */
function buildCache(table) { function buildCache(table) {
var cc, t, tx, v, i, j, k, $row, rows, cols, cacheTime, var cc, t, tx, v, i, j, k, $row, cols, cacheTime,
totalRows, rowData, colMax, totalRows, rowData, colMax,
c = table.config, c = table.config,
$tb = c.$table.children('tbody'), $tb = c.$tbodies,
extractors = c.extractors, extractors = c.extractors,
parsers = c.parsers; parsers = c.parsers;
c.cache = {}; c.cache = {};
@ -321,8 +320,6 @@
// colMax: # // added at the end // colMax: # // added at the end
}; };
// ignore tbodies with class name from c.cssInfoBlock
if (!$tb.eq(k).hasClass(c.cssInfoBlock)) {
totalRows = ($tb[k] && $tb[k].rows.length) || 0; totalRows = ($tb[k] && $tb[k].rows.length) || 0;
for (i = 0; i < totalRows; ++i) { for (i = 0; i < totalRows; ++i) {
rowData = { rowData = {
@ -333,7 +330,6 @@
}; };
/** Add the table data to main data array */ /** Add the table data to main data array */
$row = $($tb[k].rows[i]); $row = $($tb[k].rows[i]);
rows = [ new Array(c.columns) ];
cols = []; cols = [];
// if this is a child row, add it to the last row's children and continue to the next row // if this is a child row, add it to the last row's children and continue to the next row
// ignore child row class, if it is the first row // ignore child row class, if it is the first row
@ -382,7 +378,7 @@
cc.colMax = colMax; cc.colMax = colMax;
// total up rows, not including child rows // total up rows, not including child rows
c.totalRows += cc.normalized.length; c.totalRows += cc.normalized.length;
}
} }
if (c.showProcessing) { if (c.showProcessing) {
ts.isProcessing(table); // remove processing icon ts.isProcessing(table); // remove processing icon
@ -396,7 +392,7 @@
function appendToTable(table, init) { function appendToTable(table, init) {
var c = table.config, var c = table.config,
wo = c.widgetOptions, wo = c.widgetOptions,
b = table.tBodies, b = c.$tbodies,
rows = [], rows = [],
cc = c.cache, cc = c.cache,
n, totalRows, $bk, $tb, n, totalRows, $bk, $tb,
@ -412,7 +408,7 @@
} }
for (k = 0; k < b.length; k++) { for (k = 0; k < b.length; k++) {
$bk = $(b[k]); $bk = $(b[k]);
if ($bk.length && !$bk.hasClass(c.cssInfoBlock)) { if ($bk.length) {
// get tbody // get tbody
$tb = ts.processTbody(table, $bk, true); $tb = ts.processTbody(table, $bk, true);
n = cc[k].normalized; n = cc[k].normalized;
@ -754,23 +750,23 @@
// sort multiple columns // sort multiple columns
function multisort(table) { /*jshint loopfunc:true */ function multisort(table) { /*jshint loopfunc:true */
var i, k, num, col, sortTime, colMax, var i, k, num, col, sortTime, colMax,
cache, order, sort, x, y, rows, order, sort, x, y,
dir = 0, dir = 0,
c = table.config, c = table.config,
cts = c.textSorter || '', cts = c.textSorter || '',
sortList = c.sortList, sortList = c.sortList,
l = sortList.length, l = sortList.length,
bl = table.tBodies.length; bl = c.$tbodies.length;
if (c.serverSideSorting || isEmptyObject(c.cache)) { // empty table - fixes #206/#346 if (c.serverSideSorting || isEmptyObject(c.cache)) { // empty table - fixes #206/#346
return; return;
} }
if (c.debug) { sortTime = new Date(); } if (c.debug) { sortTime = new Date(); }
for (k = 0; k < bl; k++) { for (k = 0; k < bl; k++) {
colMax = c.cache[k].colMax; colMax = c.cache[k].colMax;
cache = c.cache[k].normalized; rows = c.cache[k].normalized;
cache.sort(function(a, b) { rows.sort(function(a, b) {
// cache is undefined here in IE, so don't use it! // rows is undefined here in IE, so don't use it!
for (i = 0; i < l; i++) { for (i = 0; i < l; i++) {
col = sortList[i][0]; col = sortList[i][0];
order = sortList[i][1]; order = sortList[i][1];
@ -891,7 +887,7 @@
$table.find(c.selectorRemove).remove(); $table.find(c.selectorRemove).remove();
// get position from the dom // get position from the dom
var v, t, row, icell, var v, t, row, icell,
$tb = $table.find('tbody'), $tb = c.$tbodies,
$cell = $(cell), $cell = $(cell),
// update cache - format: function(s, table, cell, cellIndex) // update cache - format: function(s, table, cell, cellIndex)
// no closest in jQuery v1.2.6 - tbdy = $tb.index( $(cell).closest('tbody') ),$row = $(cell).closest('tr'); // no closest in jQuery v1.2.6 - tbdy = $tb.index( $(cell).closest('tbody') ),$row = $(cell).closest('tr');
@ -940,7 +936,7 @@
$row = $($row).attr('role', 'row'); // make sure we're using a jQuery object $row = $($row).attr('role', 'row'); // make sure we're using a jQuery object
var i, j, l, t, v, rowData, cells, var i, j, l, t, v, rowData, cells,
rows = $row.filter('tr').length, rows = $row.filter('tr').length,
tbdy = $table.find('tbody').index( $row.parents('tbody').filter(':first') ); tbdy = c.$tbodies.index( $row.parents('tbody').filter(':first') );
// fixes adding rows to an empty table - see issue #179 // fixes adding rows to an empty table - see issue #179
if (!(c.parsers && c.parsers.length)) { if (!(c.parsers && c.parsers.length)) {
buildParserCache(table); buildParserCache(table);
@ -1200,7 +1196,7 @@
colgroup = $('<colgroup class="' + ts.css.colgroup + '">'); colgroup = $('<colgroup class="' + ts.css.colgroup + '">');
overallWidth = c.$table.width(); overallWidth = c.$table.width();
// only add col for visible columns - fixes #371 // only add col for visible columns - fixes #371
$(table.tBodies).not('.' + c.cssInfoBlock).find('tr:first').children(':visible').each(function() { c.$tbodies.find('tr:first').children(':visible').each(function() {
percent = parseInt( ( $(this).width() / overallWidth ) * 1000, 10 ) / 10 + '%'; percent = parseInt( ( $(this).width() / overallWidth ) * 1000, 10 ) / 10 + '%';
colgroup.append( $('<col>').css('width', percent) ); colgroup.append( $('<col>').css('width', percent) );
}); });

View File

@ -1146,13 +1146,12 @@ ts.filter = {
}, },
findRows: function(table, filters, combinedFilters) { findRows: function(table, filters, combinedFilters) {
if (table.config.lastCombinedFilter === combinedFilters || !table.config.widgetOptions.filter_initialized) { return; } if (table.config.lastCombinedFilter === combinedFilters || !table.config.widgetOptions.filter_initialized) { return; }
var len, $rows, rowIndex, tbodyIndex, $tbody, $cells, $cell, columnIndex, var len, norm_rows, $rows, rowIndex, tbodyIndex, $tbody, $cells, $cell, columnIndex,
childRow, lastSearch, hasSelect, matches, result, showRow, time, val, indx, childRow, lastSearch, hasSelect, matches, result, showRow, time, val, indx,
notFiltered, searchFiltered, filterMatched, excludeMatch, fxn, ffxn, notFiltered, searchFiltered, filterMatched, excludeMatch, fxn, ffxn,
regex = ts.filter.regex, regex = ts.filter.regex,
c = table.config, c = table.config,
wo = c.widgetOptions, wo = c.widgetOptions,
$tbodies = c.$table.children('tbody'), // target all tbodies #568
// data object passed to filters; anyMatch is a flag for the filters // data object passed to filters; anyMatch is a flag for the filters
data = { anyMatch: false }, data = { anyMatch: false },
// anyMatch really screws up with these types of filters // anyMatch really screws up with these types of filters
@ -1176,14 +1175,14 @@ ts.filter = {
// combindedFilters are undefined on init // combindedFilters are undefined on init
combinedFilters = (filters || []).join(''); combinedFilters = (filters || []).join('');
for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) { for (tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++ ) {
if ($tbodies.eq(tbodyIndex).hasClass(c.cssInfoBlock || ts.css.info)) { continue; } // ignore info blocks, issue #264 $tbody = ts.processTbody(table, c.$tbodies.eq(tbodyIndex), true);
$tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true);
// skip child rows & widget added (removable) rows - fixes #448 thanks to @hempel! // skip child rows & widget added (removable) rows - fixes #448 thanks to @hempel!
// $rows = $tbody.children('tr').not(c.selectorRemove); // $rows = $tbody.children('tr').not(c.selectorRemove);
columnIndex = c.columns; columnIndex = c.columns;
// convert stored rows into a jQuery object // convert stored rows into a jQuery object
$rows = $( $.map(c.cache[tbodyIndex].normalized, function(el){ return el[columnIndex].$row.get(); }) ); norm_rows = c.cache[tbodyIndex].normalized;
$rows = $( $.map(norm_rows, function(el){ return el[columnIndex].$row.get(); }) );
if (combinedFilters === '' || wo.filter_serversideFiltering) { if (combinedFilters === '' || wo.filter_serversideFiltering) {
$rows.removeClass(wo.filter_filteredRow).not('.' + c.cssChildRow).show(); $rows.removeClass(wo.filter_filteredRow).not('.' + c.cssChildRow).show();
@ -1240,7 +1239,7 @@ ts.filter = {
// loop through the rows // loop through the rows
for (rowIndex = 0; rowIndex < len; rowIndex++) { for (rowIndex = 0; rowIndex < len; rowIndex++) {
data.cacheArray = c.cache[tbodyIndex].normalized[rowIndex]; data.cacheArray = norm_rows[rowIndex];
childRow = $rows[rowIndex].className; childRow = $rows[rowIndex].className;
// skip child rows & already filtered rows // skip child rows & already filtered rows
@ -1488,10 +1487,8 @@ ts.filter = {
var rowIndex, tbodyIndex, len, row, cache, cell, var rowIndex, tbodyIndex, len, row, cache, cell,
c = table.config, c = table.config,
wo = c.widgetOptions, wo = c.widgetOptions,
$tbodies = c.$table.children('tbody'),
arry = []; arry = [];
for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) { for (tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++ ) {
if (!$tbodies.eq(tbodyIndex).hasClass(c.cssInfoBlock)) {
cache = c.cache[tbodyIndex]; cache = c.cache[tbodyIndex];
len = c.cache[tbodyIndex].normalized.length; len = c.cache[tbodyIndex].normalized.length;
// loop through the rows // loop through the rows
@ -1511,7 +1508,6 @@ ts.filter = {
} }
} }
} }
}
return arry; return arry;
}, },
buildSelect: function(table, column, arry, updating, onlyAvail) { buildSelect: function(table, column, arry, updating, onlyAvail) {

View File

@ -149,14 +149,13 @@
}, },
getRows: function(c, wo) { getRows: function(c, wo) {
// the cache may not have a zero index if there are any "info-only" tbodies above the main tbody var norm_rows = c.cache[0].normalized,
var cache = c.cache[0].normalized,
rows = []; rows = [];
chart_rows = []; chart_rows = [];
chart_categories = []; chart_categories = [];
chart_category = []; chart_category = [];
$.each(cache, function(indx, rowVal) { $.each(norm_rows, function(indx, rowVal) {
var i, txt, var i, txt,
$tr = rowVal[c.columns].$row, $tr = rowVal[c.columns].$row,
$cells = $tr.children('th,td'), $cells = $tr.children('th,td'),

View File

@ -54,7 +54,7 @@ ts.grouping = {
update : function(table, c, wo){ update : function(table, c, wo){
if ($.isEmptyObject(c.cache)) { return; } if ($.isEmptyObject(c.cache)) { return; }
var rowIndex, tbodyIndex, currentGroup, $rows, groupClass, grouping, cache, saveName, direction, var rowIndex, tbodyIndex, currentGroup, $rows, groupClass, grouping, norm_rows, saveName, direction,
lang = wo.grouping_language, lang = wo.grouping_language,
group = '', group = '',
savedGroup = false, savedGroup = false,
@ -89,15 +89,15 @@ ts.grouping = {
} }
} }
for (tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++) { for (tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++) {
cache = c.cache[tbodyIndex].normalized; norm_rows = c.cache[tbodyIndex].normalized;
group = ''; // clear grouping across tbodies group = ''; // clear grouping across tbodies
$rows = c.$tbodies.eq(tbodyIndex).children('tr').not('.' + c.cssChildRow); $rows = c.$tbodies.eq(tbodyIndex).children('tr').not('.' + c.cssChildRow);
for (rowIndex = 0; rowIndex < $rows.length; rowIndex++) { for (rowIndex = 0; rowIndex < $rows.length; rowIndex++) {
if ( $rows.eq(rowIndex).is(':visible') ) { if ( $rows.eq(rowIndex).is(':visible') ) {
// fixes #438 // fixes #438
if (ts.grouping.types[grouping[1]]) { if (ts.grouping.types[grouping[1]]) {
currentGroup = cache[rowIndex] ? currentGroup = norm_rows[rowIndex] ?
ts.grouping.types[grouping[1]]( c, c.$headers.filter('[data-column="' + column + '"]:last'), cache[rowIndex][column], /date/.test(groupClass) ? ts.grouping.types[grouping[1]]( c, c.$headers.filter('[data-column="' + column + '"]:last'), norm_rows[rowIndex][column], /date/.test(groupClass) ?
grouping[2] : parseInt(grouping[2] || 1, 10) || 1, group, lang ) : currentGroup; grouping[2] : parseInt(grouping[2] || 1, 10) || 1, group, lang ) : currentGroup;
if (group !== currentGroup) { if (group !== currentGroup) {
group = currentGroup; group = currentGroup;

View File

@ -371,8 +371,7 @@ tsp = ts.pager = {
}, },
calcFilters: function(table, c) { calcFilters: function(table, c) {
var tbodyIndex, var wo = c.widgetOptions,
wo = c.widgetOptions,
p = c.pager, p = c.pager,
hasFilters = c.$table.hasClass('hasFilters'); hasFilters = c.$table.hasClass('hasFilters');
if (hasFilters && !wo.pager_ajaxUrl) { if (hasFilters && !wo.pager_ajaxUrl) {
@ -380,10 +379,8 @@ tsp = ts.pager = {
// delayInit: true so nothing is in the cache // delayInit: true so nothing is in the cache
p.filteredRows = p.totalRows = c.$tbodies.eq(0).children('tr').not( wo.pager_countChildRows ? '' : '.' + c.cssChildRow ).length; p.filteredRows = p.totalRows = c.$tbodies.eq(0).children('tr').not( wo.pager_countChildRows ? '' : '.' + c.cssChildRow ).length;
} else { } else {
// just in case the pager tbody isn't the first tbody
tbodyIndex = c.$table.children('tbody').index( c.$tbodies.eq(0) );
p.filteredRows = 0; p.filteredRows = 0;
$.each(c.cache[tbodyIndex].normalized, function(i, el) { $.each(c.cache[0].normalized, function(i, el) {
p.filteredRows += p.regexRows.test(el[c.columns].$row[0].className) ? 0 : 1; p.filteredRows += p.regexRows.test(el[c.columns].$row[0].className) ? 0 : 1;
}); });
} }
@ -898,8 +895,7 @@ tsp = ts.pager = {
if ( !$.isEmptyObject(table.config.cache) ) { if ( !$.isEmptyObject(table.config.cache) ) {
var i, var i,
rows = [], rows = [],
tbodyIndex = c.$table.children('tbody').index( c.$tbodies.eq(0) ), n = table.config.cache[0].normalized;
n = table.config.cache[tbodyIndex].normalized;
p.totalRows = n.length; p.totalRows = n.length;
for (i = 0; i < p.totalRows; i++) { for (i = 0; i < p.totalRows; i++) {
rows.push(n[i][c.columns].$row); rows.push(n[i][c.columns].$row);

View File

@ -31,7 +31,7 @@ var tester = {
var i, j = 0, k, l, var i, j = 0, k, l,
c = table.config, c = table.config,
result = [], result = [],
b = table.tBodies, b = c.$tbodies,
l2 = c.columns; l2 = c.columns;
for (k = 0; k < b.length; k++){ for (k = 0; k < b.length; k++){
l = b[k].rows.length; l = b[k].rows.length;
@ -423,7 +423,8 @@ $(function(){
expect(4); expect(4);
$table1.trigger('sorton', [[[ 0,0 ]]]); $table1.trigger('sorton', [[[ 0,0 ]]]);
tester.cacheCompare( table1, 0, [ 'test1', 'test2', 'test3', '', 'testa', 'testb', 'testc' ], 'from data-attribute' ); tester.cacheCompare( table1, 0, [ 'test1', 'test2', 'test3',
'testa', 'testb', 'testc' ], 'from data-attribute' );
$table3.trigger('sorton', [[[ 0,1 ]]]); $table3.trigger('sorton', [[[ 0,1 ]]]);
tester.cacheCompare( table3, 0, [ '', 'a255', 'a102', 'a87', 'a55', 'a43', 'a33', 'a10', 'a02', 'a1' ], 'ignore data-attribute' ); tester.cacheCompare( table3, 0, [ '', 'a255', 'a102', 'a87', 'a55', 'a43', 'a33', 'a10', 'a02', 'a1' ], 'ignore data-attribute' );
@ -442,13 +443,16 @@ $(function(){
$table1.trigger('sortReset'); $table1.trigger('sortReset');
// lower case because table was parsed before c1.ignoreCase was changed // lower case because table was parsed before c1.ignoreCase was changed
tester.cacheCompare( table1, 'all', [ 'test2', 'x2', 'test1', 'x3', 'test3', 'x1', '', '', 'testb', 'x5', 'testc', 'x4', 'testa', 'x6' ], 'unsorted' ); tester.cacheCompare( table1, 'all', [ 'test2', 'x2', 'test1', 'x3', 'test3', 'x1',
'testb', 'x5', 'testc', 'x4', 'testa', 'x6' ], 'unsorted' );
$table1.trigger('sorton', [[[ 0,0 ]]]); $table1.trigger('sorton', [[[ 0,0 ]]]);
tester.cacheCompare( table1, 'all', [ 'test1', 'x3', 'test2', 'x2', 'test3', 'x1', '', '', 'testa', 'x6', 'testb', 'x5', 'testc', 'x4' ], 'ascending sort' ); tester.cacheCompare( table1, 'all', [ 'test1', 'x3', 'test2', 'x2', 'test3', 'x1',
'testa', 'x6', 'testb', 'x5', 'testc', 'x4' ], 'ascending sort' );
$table1.trigger('sorton', [[[ 0,1 ]]]); $table1.trigger('sorton', [[[ 0,1 ]]]);
tester.cacheCompare( table1, 'all', [ 'test3', 'x1', 'test2', 'x2', 'test1', 'x3', '', '', 'testc', 'x4', 'testb', 'x5', 'testa', 'x6' ], 'descending sort' ); tester.cacheCompare( table1, 'all', [ 'test3', 'x1', 'test2', 'x2', 'test1', 'x3',
'testc', 'x4', 'testb', 'x5', 'testa', 'x6' ], 'descending sort' );
// empty cell position // empty cell position
$table3.trigger('sorton', [[[ 0,0 ]]]); $table3.trigger('sorton', [[[ 0,0 ]]]);
@ -569,36 +573,40 @@ $(function(){
hl = c1.headerList[1] === nw, hl = c1.headerList[1] === nw,
p1 = c1.parsers[1].id === 'digit'; p1 = c1.parsers[1].id === 'digit';
equal(hc && hd && hl && p1, true, 'testing header cache: updateAll - thead'); equal(hc && hd && hl && p1, true, 'testing header cache: updateAll - thead');
tester.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, '', '', 'testc', 4, 'testb', 5, 'testa', 6 ], 'updateAll - tbody' ); tester.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3,
'testc', 4, 'testb', 5, 'testa', 6 ], 'updateAll - tbody' );
}]); }]);
// addRows // addRows
t = $('<tr class="temp"><td>testd</td><td>7</td></tr>'); t = $('<tr class="temp"><td>testd</td><td>7</td></tr>');
$table1.find('tbody:last').prepend(t); $table1.find('tbody:last').prepend(t);
oldColMax = c1.cache[2].colMax[1]; oldColMax = c1.cache[1].colMax[1];
$table1.trigger('addRows', [t, true, function(){ $table1.trigger('addRows', [t, true, function(){
updateCallback++; updateCallback++;
equal( oldColMax === 6 && c1.cache[2].colMax[1] === 7, true, 'addRows includes updating colMax value'); equal( oldColMax === 6 && c1.cache[1].colMax[1] === 7, true, 'addRows includes updating colMax value');
tester.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, '', '', 'testd', 7, 'testc', 4, 'testb', 5, 'testa', 6 ], 'addRows method' ); tester.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3,
'testd', 7, 'testc', 4, 'testb', 5, 'testa', 6 ], 'addRows method' );
}]); }]);
// updateCell // updateCell
t = $table1.find('td:contains("7")'); t = $table1.find('td:contains("7")');
t.html('-8'); t.html('-8');
oldColMax = c1.cache[2].colMax[1]; oldColMax = c1.cache[1].colMax[1];
$table1.trigger('updateCell', [t[0], true, function(){ $table1.trigger('updateCell', [t[0], true, function(){
updateCallback++; updateCallback++;
equal( oldColMax === 7 && c1.cache[2].colMax[1] === 8, true, 'updateCell includes updating colMax value'); equal( oldColMax === 7 && c1.cache[1].colMax[1] === 8, true, 'updateCell includes updating colMax value');
tester.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, '', '', 'testd', -8, 'testc', 4, 'testb', 5, 'testa', 6 ], 'updateCell method' ); tester.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3,
'testd', -8, 'testc', 4, 'testb', 5, 'testa', 6 ], 'updateCell method' );
}]); }]);
// update // update
$table1.find('tr.temp').remove(); $table1.find('tr.temp').remove();
oldColMax = c1.cache[2].colMax[1]; oldColMax = c1.cache[1].colMax[1];
$table1.trigger('update', [true, function(){ $table1.trigger('update', [true, function(){
updateCallback++; updateCallback++;
equal( oldColMax === 8 && c1.cache[2].colMax[1] === 6, true, 'update includes updating colMax value'); equal( oldColMax === 8 && c1.cache[1].colMax[1] === 6, true, 'update includes updating colMax value');
tester.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, '', '', 'testc', 4, 'testb', 5, 'testa', 6 ], 'update method' ); tester.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3,
'testc', 4, 'testb', 5, 'testa', 6 ], 'update method' );
}]); }]);
$table5 $table5