vue-tables-2
  • Dependencies & Compatability
  • Getting Started
    • Vue Version 3
  • Client Table
    • Asynchronous Loading
    • Grouping
    • Filtering Algorithm
    • Editable Cells
  • Server Table
    • Implementations
    • Custom Request Function
    • Setting Multiple Request Parameters
    • Error Message
    • Draw Counter
  • Virtual Pagination
  • Custom Template
  • Column Templates
  • Nested Data Structures
  • Selectable Rows
  • Date Columns
  • List Filters
  • Custom Filters
  • Custom Sorting
  • Multiple Sorting
  • Child Rows
  • Conditional Cell Styling
  • Columns Visibility
  • Methods
  • Properties
  • Events
  • Slots
  • Options API
Powered by GitBook
On this page
  • Client Side Sorting
  • Server Side Sorting

Was this helpful?

Custom Sorting

Client Side Sorting

Sometimes you may wish to override the default sorting logic which is applied uniformly to all columns.

To do so use the customSorting option. This is an object that recieves custom logic for specific columns.

E.g, to sort the name column by the last character:

customSorting: {
    name: function (ascending) {
        return function (a, b) {
            var lastA = a.name[a.name.length - 1].toLowerCase();
            var lastB = b.name[b.name.length - 1].toLowerCase();

            if (ascending)
                return lastA >= lastB ? 1 : -1;

            return lastA <= lastB ? 1 : -1;
        }
    }
}

Server Side Sorting

This depends entirely on your backend implemetation as the library sends the sorting directions through the request.

PreviousCustom FiltersNextMultiple Sorting

Last updated 5 years ago

Was this helpful?