Our blazing fast Grid component built with pure JavaScript


Post by Webethics »

Hello

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

Thanks


Post 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

Best regards,
Márcio


Post Reply