Permalink
Browse files

delayInit option

  • Loading branch information...
Mottie committed May 8, 2012
1 parent 13200fd commit 5d0224d895bd5c6ca1b12e5d8c35654cd75389c0
View
Binary file not shown.
View
@@ -336,7 +336,7 @@ <h4>Playgrounds & Other demos</h4>
<h4>Metadata - setting inline options</h4>
<ul>
- <li>*Note* you can use class names (version 2.0.11+, <a href="example-parsers-class-name.html">demo</a>), or jQuery data (version 2.2.3+, <a href="example-parsers-jquery-data.html">demo</a>) instead of meta data</li>
+ <li>*Note* you can use class names (version 2.0.11+, <a href="example-parsers-class-name.html">demo</a>), or jQuery data (version 2.3+, <a href="example-parsers-jquery-data.html">demo</a>) instead of meta data</li>
<li><a href="example-meta-sort-list.html">Set a initial sorting order using metadata.</a></li>
<li><a href="example-meta-headers.html">Disable header using metadata</a></li>
<li><a href="example-meta-parsers.html">Setting column parser using metadata</a></li>
@@ -563,7 +563,17 @@ <h1>Configuration</h1>
<td>Boolean</td>
<td>false</td>
<td>
- Boolean flag indicating if tablesorter should display debuging information usefull for development.
+ Boolean flag indicating if tablesorter should display debuging information useful for development.
+ </td>
+ <td><a href="example-option-debug.html">Example</a></td>
+ </tr>
+
+ <tr id="delayinit">
+ <td><span class="permalink">delayInit</span></td>
+ <td>Boolean</td>
+ <td>false</td>
+ <td>
+ Setting this option to true will delay parsing of all table cell data until the user initializes a sort. This speeds up the initialization process of very large tables, but the data still needs to be parsed, so the delay is still present upon initial sort.
</td>
<td><a href="example-option-debug.html">Example</a></td>
</tr>
View
@@ -31,6 +31,7 @@
dateFormat : "mmddyyyy", // other options: "ddmmyyy" or "yyyymmdd"
sortMultiSortKey : "shiftKey", // key used to select additional columns
usNumberFormat : true, // false for German "1.234.567,89" or French "1 234 567,89"
+ delayInit : false, // if false, the parsed table contents will not update until the first sort.
// sort options
headers : {}, // set sorter, string, empty, locked order, sortInitialOrder, filter, etc.
@@ -163,7 +164,7 @@
m = $.metadata ? h.metadata() : false,
cl = h.attr('class') || '';
if (h.data() && typeof h.data(key) !== 'undefined'){
- val = h.data(key) + '';
+ val += h.data(key);
} else if (m && m[key]) {
val = m[key];
} else if (ch && ch[key]) {
@@ -425,7 +426,7 @@
}
function setHeadersCss(table, $headers, list) {
- var f, h = [], i, l, css = [table.config.cssDesc, table.config.cssAsc];
+ var f, h = [], i, j, l, css = [table.config.cssDesc, table.config.cssAsc];
// remove all header information
$headers
.removeClass(css.join(' '))
@@ -441,11 +442,11 @@
// multicolumn sorting updating
f = $headers.filter('[data-column="' + list[i][0] + '"]');
if (l > 1 && f.length) {
- f.each(function(){
- if (!this.sortDisabled) {
- $(this).addClass(css[list[i][1]]);
+ for (j = 0; j < f.length; j++) {
+ if (!f[j].sortDisabled) {
+ $(f[j]).addClass(css[list[i][1]]);
}
- });
+ }
}
}
}
@@ -629,13 +630,15 @@
// try to auto detect column type, and store in tables config
c.parsers = buildParserCache(this, $headers);
// build the cache for the tbody cells
- buildCache(this);
+ // delayInit will delay building the cache until the user starts a sort
+ if (!c.delayInit) { buildCache(this); }
// fixate columns if the users supplies the fixedWidth option
fixColumnWidth(this);
// apply event handling to headers
// this is to big, perhaps break it out?
$headers
.click(function(e) {
+ if (c.delayInit && !c.cache) { buildCache($this[0]); }
if (!this.sortDisabled) {
// Only call sortStart if sorting is enabled.
$this.trigger("sortStart", $this[0]);
Oops, something went wrong.

0 comments on commit 5d0224d

Please sign in to comment.