-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sorting and | for sort order. #55
Comments
@tmikaeld Can you please explain more about this? |
If i set: I will get While in the API I'm consuming, sort order is defined with |
@tmikaeld OK. I think of something and let you know. May not be tonight though. |
@tmikaeld What I would do is to modify getSortParam() a bit that it will check if there is So, you could effectively override how the sort parameter would be constructed before sending it to the server in the This way I don't have to introduce another prop. |
This was the best i could come up with without creating a new prop. With this you just set
The change in vue-table.js, from line 661: getSortParam: function getSortParam() {
if (!this.sortOrder || this.sortOrder.field == '') {
return '';
}
var result = '';
for (var i = 0; i < this.sortOrder.length; i++) {
var fieldName = typeof this.sortOrder[i].sortField === 'undefined' ? this.sortOrder[i].field : this.sortOrder[i].sortField;
console.log(this.sortOrder[i].seperator)
//Support for -fieldName fieldName as ascending/descending sort order instead of fieldName|desc fieldName|asc
if(!this.sortOrder[i].seperator == '+-') {
result += fieldName + '|' + this.sortOrder[i].direction + (i + 1 < this.sortOrder.length ? ',' : '');
} else {
if(this.sortOrder[i].direction == 'asc') {
result += fieldName.replace('-','') + (i + 1 < this.sortOrder.length ? ',' : '');
} else {
result += '-'+fieldName.replace('-','') + (i + 1 < this.sortOrder.length ? ',' : '');
}
}
}
return result;
}, Let me know if it's good enough to include to the library. |
That's certainly more flexible, thanks! |
My API doesn't use | seperator for sort order, this should be an option not a requirement (It's added even if direction: '' is empty.
The text was updated successfully, but these errors were encountered: