Permalink
Browse files

fix issue #55 & updated docs

  • Loading branch information...
1 parent 0176a41 commit b9830622f38610c4c356bc8841c6a5b85fbaf524 @Mottie committed Apr 24, 2012
View
@@ -35,6 +35,15 @@ tablesorter can successfully parse and sort many types of data including linked
View the [complete listing here](https://github.com/Mottie/tablesorter/wiki/Change).
+#### Version 2.1.19 (4/23/2012)
+
+* The filter widget will now ignore leading spaces so when the `filter_startsWith` is `true` it will match the text. Fix from [issue #55](https://github.com/Mottie/tablesorter/issues/55). Thanks to [aarkay18](https://github.com/aarkay18) for the code!
+* Fixed a problem with empty table cells returning an empty string instead of parsing the cell - needed when there is HTML like an input tag to process. Reverted the change accidently added back in version 2.1.15.
+* Added a resort flag that when set to false, it will prevent the resorting of the table when "update", "updateCell" or "addRows" is called. Use the appropriate format below:
+ * *update*: `$('table').trigger('update', [false]);
+ * *updateCell*: `$('table').trigger('updateCell', [ this, false ]);` - see the [updating a table cell](http://mottie.github.com/tablesorter/docs/example-update-cell.html) demo.
+ * *addRows*: `$('table').trigger('addRows', [$row, false]);` - see the [adding table rows](http://mottie.github.com/tablesorter/docs/example-add-rows.html) demo.
+
#### Version 2.1.18 (4/23/2012)
* When the sticky headers widget is applied to a table with multiple header rows, adding the class name `sticky-false` to any header row will prevent it from becoming sticky. Thanks to [megatom](https://github.com/megatom) for the suggestion in [issue #52](https://github.com/Mottie/tablesorter/issues/52#issuecomment-5261303)!
@@ -32,10 +32,13 @@
// add two rows
var row = '<tr><td>Frank</td><td>Smith</td><td>53</td><td>$39.95</td><td>22%</td><td>Mar 22, 2011 9:33 AM</td></tr>' +
'<tr><td>Inigo</td><td>Montoya</td><td>34</td><td>$19.99</td><td>15%</td><td>Sep 25, 1987 12:00PM</td></tr>',
- $row = $(row);
+ $row = $(row),
+ // resort table using the current sort; set to false to prevent resort, otherwise
+ // any other value in resort will automatically trigger the table resort.
+ resort = true;
$('table')
.find('tbody').append($row)
- .trigger('addRows', [$row]);
+ .trigger('addRows', [$row, resort]);
});
});</script>
View
@@ -29,7 +29,10 @@
$("table tbody").append(html);
// let the plugin know that we made a update
- $("table").trigger("update");
+ // the resort flag set to anything BUT false (no quotes) will trigger an automatic
+ // table resort using the current sort
+ var resort = true;
+ $("table").trigger("update", [resort]);
// triggering the "update" function will resort the table using the current sort; since version 2.0.14
// use the following code to change the sort; set sorting column and direction, this will sort on the first and third column
@@ -28,10 +28,13 @@
$("table tbody td.discount").click(function() {
// randomize a number
- var discount = '$' + Math.round(Math.random() * Math.random() * 100) + '.' + ('0' + Math.round(Math.random() * Math.random() * 100)).slice(-2);
+ var resort = "", // resort variable set to anything BUT false (without quotes) will trigger the automatic resort
+ discount = '$' + Math.round(Math.random() * Math.random() * 100) + '.' + ('0' + Math.round(Math.random() * Math.random() * 100)).slice(-2);
$(this).text(discount);
- $("table").trigger("updateCell",[this]);
+ // set resort flag to false to prevent automatic resort
+ // leave the resort flag as undefined, or with any other value, to automatically resort the table
+ $("table").trigger("updateCell",[this, resort]);
return false;
});
View
@@ -1286,10 +1286,13 @@
<pre class="js">// Add multiple rows to the table
var row = '&lt;tr&gt;&lt;td&gt;Inigo&lt;/td&gt;&lt;td&gt;Montoya&lt;/td&gt;&lt;td&gt;34&lt;/td&gt;' +
'&lt;td&gt;$19.99&lt;/td&gt;&lt;td&gt;15%&lt;/td&gt;&lt;td&gt;Sep 25, 1987 12:00PM&lt;/td&gt;&lt;/tr&gt;',
- $row = $(row);
+ $row = $(row),
+ // resort table using the current sort; set to false to prevent resort, otherwise
+ // any other value in resort will automatically trigger the table resort.
+ resort = true;
$('table')
.find('tbody').append($row)
- .trigger('addRows', [$row]);</pre></div>
+ .trigger('addRows', [$row, resort]);</pre></div>
</td>
<td><a href="example-add-rows.html">Example</a></td>
</tr>
@@ -1314,7 +1317,10 @@
$("table tbody").append(html);
// let the plugin know that we made a update
-$("table").trigger("update");
+// the resort flag set to anything BUT false (no quotes) will trigger an automatic
+// table resort using the current sort
+var resort = true;
+$("table").trigger("update", [resort]);
// As of version 2.0.14, the table will automatically resort (using the current sort selection)
// after the update, so include the following if you want to specify a different sort
@@ -1351,19 +1357,23 @@
$("td.discount").click(function(){
// randomize a number
- var discount = '$' + Math.round(Math.random() * Math.random() * 100) + '.' +
+ var resort = false,
+ discount = '$' + Math.round(Math.random() * Math.random() * 100) + '.' +
('0' + Math.round(Math.random() * Math.random() * 100)).slice(-2);
$(this).text(discount);
// update the table, so the tablesorter plugin knows its value
- $("table").trigger("updateCell",[this]);
+ // set resort flag to false to prevent automatic resort (since we're using a different sort below)
+ // leave the resort flag as undefined, or with any other value, to automatically resort the table
+ // $("table").trigger("updateCell", [this]); < - resort is undefined so the table WILL resort
+ $("table").trigger("updateCell", [this, resort]);
// As of version 2.0.14, the table will automatically resort (using the current sort selection)
// after the update, so include the following if you want to specify a different sort
// set sorting column and direction, this will sort on the first and third column
var sorting = [[3,1]];
- $("table").trigger("sorton",[sorting]);
+ $("table").trigger("sorton", [sorting]);
return false;
});

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -202,7 +202,7 @@ $.tablesorter.addWidget({
typeof wo.filter_childRows !== 'undefined' ? wo.filter_childRows : true)) ? cr.text() : '';
$td = $(this).find('td');
for (i=0; i < cols; i++){
- x = ($td.eq(i).text() + t).toLowerCase().indexOf(v[i]);
+ x = $.trim(($td.eq(i).text() + t)).toLowerCase().indexOf(v[i]);
if (v[i] !== '' && ( (!wo.filter_startsWith && x >= 0) || (wo.filter_startsWith && x === 0) ) ) {
r = (r) ? true : false;
} else if (v[i] !== '') {

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,6 +1,6 @@
-{
+{
"name": "tablesorter",
- "version": "2.1.18",
+ "version": "2.1.19",
"title": "tablesorter",
"author": {
"name": "Christian Bach",

0 comments on commit b983062

Please sign in to comment.