Page 1 of 1

[VUE 2] sorting by columns without first row

Posted: Mon Jul 25, 2022 3:08 pm
by Webethics

Hello

How can we use sort by columns for grid except first row?

Thanks


Re: [VUE 2] sorting by columns without first row

Posted: Mon Jul 25, 2022 4:00 pm
by marcio

Hey Webethics,

You can achieve that using the custom sorter function like this

const grid = new Grid({
    ... Other configurations
    store : {
        sorters : [{
            fn : (recordA, recordB) => {
                const [store] = recordA.stores; // Get the store reference
                const { first } = store; // Get the first register of the store
                // If it's the first register, always put it in first place
                if (first.id === recordB.id) {
                    return 1;
                }
                // apply custom logic, for example:
                return recordA.name.localeCompare(recordB.name);
            }
        }]
    },

https://www.bryntum.com/docs/grid/api/Grid/feature/Sort
https://www.bryntum.com/docs/grid/api/Core/data/Store#property-first