Premium support for our pure JavaScript UI components


Post by jeffrey1994 »

I'm trying to create a custom column and set a custom sorter, but it seems like it doesn't work.
If I retrieve the column from the ColumnStore the sortable property = {} (just an empty object).
What does seem to work is setting "sortable" to undefined and then setting my custom sorter.

I can't seem this get this working in an example so I hope this is enough info.

Btw setting filterable config option via static defaults getter does work properly.

class CustomColumn extends Column {
    static get type() {
        return 'custom';
    }

// does not work
static get defaults() {
    return { 
        sortable: () => {
            console.log('test');
        }
    };
}

public construct(config) {
    // does not work
    config.sortable = () => {
        console.log('test');
    };
    
    super.construct(...arguments);
    
    this.sortable = undefined;
    // works due to line above
    this.sortable = () => {
        console.log('test');
    };
}
}
ColumnStore.registerColumnType(CustomColumn);
Last edited by jeffrey1994 on Tue Nov 23, 2021 5:28 pm, edited 2 times in total.

Post by alex.l »

Column is a model, so the correct way to define default values is:

class ColorColumn extends Column {
    static get type() {
        return 'color';
    }

static get defaults() {
    return {
        sortable(rec1, rec2) {
            console.log(1);
            return rec1.name < rec2.name ? -1 : 1;
        }
    };
}

defaults should return an object.

All the best,
Alex


Post by jeffrey1994 »

alex.l wrote: Tue Nov 23, 2021 2:49 pm

Column is a model, so the correct way to define default values is:

class ColorColumn extends Column {
    static get type() {
        return 'color';
    }

static get defaults() {
    return {
        sortable(rec1, rec2) {
            console.log(1);
            return rec1.name < rec2.name ? -1 : 1;
        }
    };
}

defaults should return an object.

Sorry that's what I had, my example code was just wrong.
This doesn't work


Post by jeffrey1994 »

Sorry, I was overriding the defaults which is why it was not working, my bad lol.


Post Reply