Add sortReset method callback

This commit is contained in:
Mottie 2014-04-19 09:33:10 -05:00
parent 872325a458
commit 8d72efd889
2 changed files with 17 additions and 8 deletions

View File

@ -3502,12 +3502,18 @@ $("table").trigger("sorton", [sort, callback]);</pre>
<tr id="sortreset-method">
<td><a href="#" class="permalink">sortReset</a></td>
<td>Use this method to reset the table to it's initial unsorted state (v2.4.7).
<td>Use this method to reset the table to it's initial unsorted state (v2.4.7; <span class="version updated">v2.16.0</span>).
<div class="collapsible">
<br>
This method immediately resets the entire table sort, while the option only resets the column sort after a third click.
This method immediately resets the entire table sort, while the option only resets the column sort after a third click.<br>
<br>
In <span class="version updated">v2.16.0</span>, a callback function was added to this method.<br>
<br>
<pre class="prettyprint lang-js">// Reset the table (make it unsorted)
$("table").trigger("sortReset");</pre>
var callback = function(table) {
console.log('sort has been reset');
};
$("table").trigger("sortReset", [callback]);</pre>
<span class="label label-warning">*NOTE*</span> Don't confuse this method with the <a href="#sortreset"><code>sortReset</code> option</a>.
</div>
</td>

View File

@ -727,7 +727,7 @@
if (table.isUpdating) {
$table.trigger('updateComplete');
}
if (typeof callback === "function") {
if ($.isFunction(callback)) {
callback($table[0]);
}
}
@ -752,12 +752,15 @@
// apply easy methods that trigger bound events
$table
.unbind('sortReset update updateRows updateCell updateAll addRows updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave '.split(' ').join(c.namespace + ' '))
.bind("sortReset" + c.namespace, function(e){
.bind("sortReset" + c.namespace, function(e, callback){
e.stopPropagation();
c.sortList = [];
setHeadersCss(table);
multisort(table);
appendToTable(table);
if ($.isFunction(callback)) {
callback(table);
}
})
.bind("updateAll" + c.namespace, function(e, resort, callback){
e.stopPropagation();
@ -852,14 +855,14 @@
$table
.trigger("sortEnd", this)
.trigger('applyWidgets');
if (typeof callback === "function") {
if ($.isFunction(callback)) {
callback(table);
}
})
.bind("appendCache" + c.namespace, function(e, callback, init) {
e.stopPropagation();
appendToTable(table, init);
if (typeof callback === "function") {
if ($.isFunction(callback)) {
callback(table);
}
})
@ -870,7 +873,7 @@
}
// rebuild the cache map
buildCache(table);
if (typeof callback === "function") {
if ($.isFunction(callback)) {
callback(table);
}
})