mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Add "updateCache" method
This commit is contained in:
parent
5992089f9d
commit
873ff61f5f
@ -3416,17 +3416,35 @@ $("table").trigger("updateAll", [ resort, callback ]);</pre></div>
|
|||||||
<td><a href="example-update-all.html">Example</a></td>
|
<td><a href="example-update-all.html">Example</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr id="updatecache">
|
||||||
|
<td><a href="#" class="permalink">updateCache</a></td>
|
||||||
|
<td>Update the parsers, only if not defined, then update the internal cache (<span class="version">v2.15.4</span>).
|
||||||
|
<div class="collapsible">
|
||||||
|
<br>
|
||||||
|
This method is used by the pager (addon & widget) to update the data stored within the cache after the content has been updated using ajax.
|
||||||
|
<pre class="prettyprint lang-js">$("table").trigger("updateCache");</pre></div>
|
||||||
|
</td>
|
||||||
|
<td><a href="example-update-all.html">Example</a></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr id="appendcache">
|
<tr id="appendcache">
|
||||||
<td><a href="#" class="permalink">appendCache</a></td>
|
<td><a href="#" class="permalink">appendCache</a></td>
|
||||||
<td>Update a table that has had its data dynamically changed; used in conjunction with "update".<br>
|
<td>Adds all of the cached table rows back into the table.<br>
|
||||||
<div class="collapsible">
|
<div class="collapsible"><br>
|
||||||
Use this method when more than just one cell like in the "updateCell" method, but you may possibly have to trigger two events: both "update" and "appendCache".<br>
|
This method was originally designed to be used with the pager. It should be used under these conditions:
|
||||||
<br>
|
<ul>
|
||||||
Note: This is the only method the pager widget uses - the entire table is stored in the cache, but only the visible portion is actually exists in the table.
|
<li>When the pager <code>removeRows</code> option is <code>true</code>.</li>
|
||||||
<pre class="prettyprint lang-js">// Table data was just dynamically changed (more than one cell)
|
<li>When not using the "updateCell" or "addRows" methods.</li>
|
||||||
|
<li>Before manually adding or removing table rows.</li>
|
||||||
|
<li>And, before triggering an "update".</li>
|
||||||
|
</ul>
|
||||||
|
Note: The entire table is stored in the cache, but when using the pager with the <a href="#pager-removerows"><code>removeRows</code> option</a> set to <code>true</code>, only the visible portion is actually exists within the table. So, use this option to add all stored rows back into the table before manually changing the contents. Otherwise, if any update method is triggered, only the visible rows will be added back to the cache.
|
||||||
|
<pre class="prettyprint lang-js">// how to update the table contents
|
||||||
$("table")
|
$("table")
|
||||||
.trigger("update")
|
.trigger("appendCache")
|
||||||
.trigger("appendCache");</pre></div>
|
.append('<tr>...</tr>') // add new row(s), or delete rows
|
||||||
|
.trigger("update"); // update the cache</pre>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -777,7 +777,7 @@
|
|||||||
$table = c.$table;
|
$table = c.$table;
|
||||||
// apply easy methods that trigger bound events
|
// apply easy methods that trigger bound events
|
||||||
$table
|
$table
|
||||||
.unbind('sortReset update updateRows updateCell updateAll addRows sorton appendCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave '.split(' ').join('.tablesorter '))
|
.unbind('sortReset update updateRows updateCell updateAll addRows sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave '.split(' ').join('.tablesorter '))
|
||||||
.bind("sortReset.tablesorter", function(e){
|
.bind("sortReset.tablesorter", function(e){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
c.sortList = [];
|
c.sortList = [];
|
||||||
@ -878,6 +878,17 @@
|
|||||||
callback(table);
|
callback(table);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.bind("updateCache.tablesorter", function(e, callback){
|
||||||
|
// rebuild parsers
|
||||||
|
if (!c.parsers) {
|
||||||
|
buildParserCache(table);
|
||||||
|
}
|
||||||
|
// rebuild the cache map
|
||||||
|
buildCache(table);
|
||||||
|
if (typeof callback === "function") {
|
||||||
|
callback(table);
|
||||||
|
}
|
||||||
|
})
|
||||||
.bind("applyWidgetId.tablesorter", function(e, id) {
|
.bind("applyWidgetId.tablesorter", function(e, id) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
ts.getWidgetById(id).format(table, c, c.widgetOptions);
|
ts.getWidgetById(id).format(table, c, c.widgetOptions);
|
||||||
|
Loading…
Reference in New Issue
Block a user