Kendo-angular: Inconsistent Grid sorting descriptors when unsorting is allowed

Created on 11 Aug 2017  路  5Comments  路  Source: telerik/kendo-angular

I'm submitting a...

  • Suggestion for improvement

Current behavior

When a Grid column is unsorted, the exposed sorting descriptor include an item for this column with 'undefined' direction.

Expected behavior

The sorting descriptor for the unsorted column should be either removed, or the direction in the type definition should allow 'undefined'.

Internal info: reported in TicketID: 1123749

Bug Enhancement grid

Most helpful comment

The data-query is already handing this for you. However, normalizing the descriptors should be easy - just a simple filter, something like:

    protected sortChange(sort: SortDescriptor[]): void {
        this.sort = sort.filter(x => x.dir !== undefined);
        this.loadProducts();
    }

Anyway, we may consider changing the behavior and returning only descriptors with direction, in a future version of the Grid component.

All 5 comments

fixed with 1.0.7 version of kendo-data-query package.

hello, I dont think this is properly fixed in 1.0.7 as this is the version we are using now and we still get SortDescriptor with undefined direction for unsorted column

The fix is questions updates the SortDescriptor's type declaration to allow dir field to be undefined.

In case you are not using one of the provided by the _data-query package_ sorting methods, you will need to skip processing the SortDescriptors without direction.

Isn't that a bit inconsistent? Shouldn't then also initial array of sort descriptor be filled with sortDescriptors for all columns with undefined direction?
Whats the difference between no sortDescriptor and sortDescriptor with undefined dir? Seems to represent the same thing now - unsorted column, it just creates a bit of a mess, because now you also need to check the dir to know if the column is really sorted or not...
so now the sortDescriptors keep changing between undefined dir and disappearing completely when you sort different columns

The data-query is already handing this for you. However, normalizing the descriptors should be easy - just a simple filter, something like:

    protected sortChange(sort: SortDescriptor[]): void {
        this.sort = sort.filter(x => x.dir !== undefined);
        this.loadProducts();
    }

Anyway, we may consider changing the behavior and returning only descriptors with direction, in a future version of the Grid component.

Was this page helpful?
0 / 5 - 0 ratings