Premium support for our pure JavaScript UI components


Post by melazhadi »

i want to customize the id field it now takes me the value of a field return by the web service but i want it to be created from the concatenation of two value "field1" + "_" + "fields2"

is it possible?

Post by sergey.maltsev »

Hi, melazhadi!

You could use your own model class and override generateId() or set your own id field getter /setter.
https://www.bryntum.com/docs/grid/#Common/data/Model#function-
generateId
https://www.bryntum.com/docs/grid/#Common/data/Store#config-modelClass

For example (for locally created data)
class Task extends EventModel {
    generateId() {
        return this.data.field1 + '_' + this.data.field1; 
    }
}
or
class Task extends EventModel {
    static get fields() {
        return [
            'field1',
            'field2',
            'myField'
        ];
    }
    get myField() {
        return this.data.field1 + '_' + this.data.field1;
    }

    set myField(value) {
        return [this.data.field1, this.data.field1] = value.split('_');
    }
}

Task.idField = 'myField';

Post Reply