add sort order to onSort function arguments #1332

Merged
merged 1 commit into from Oct 27, 2015

Projects

None yet

2 participants

@SergioCrisostomo
Member

When sorting a table the onSort function does not tell which direction the sort happens.
Following @oskarkrawczyk 's work I made this PR to fix that.

This would make possible to know if if the reversed state is true or false.

fixes #1193

@anutron anutron and 1 other commented on an outdated diff Oct 27, 2015
Docs/Interface/HtmlTable.Sort.md
@@ -40,7 +40,7 @@ HtmlTable Method: constructor
### Events
-* sort - callback executed when a column is sorted; passed the *tbody* and the index of the column sorted.
+* sort - callback executed when a column is sorted; passed the *tbody*, the index of the column sorted and *reversed* to know the sorting direction.
@anutron
anutron Oct 27, 2015 Member

this isn't super clear. I'd do:

sort - callback executed when a column is sorted; passed the *tbody* (Element), the index of the column sorted (Integer) and which direction the table is sorted ("asc" or "desc").

@anutron anutron commented on an outdated diff Oct 27, 2015
Source/Interface/HtmlTable.Sort.js
this.setRowSort(data, pre);
if (rel) rel.grab(this.body);
this.fireEvent('stateChanged');
- return this.fireEvent('sort', [this.body, this.sorted.index]);
+ return this.fireEvent('sort', [this.body, this.sorted.index, reversed]);
@anutron
anutron Oct 27, 2015 Member

and then this would be reversed ? 'desc' : 'asc'

@SergioCrisostomo SergioCrisostomo merged commit c6a90c3 into mootools:master Oct 27, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment