Is there a way to configure the fields of a model without having to implement the static function of the fields?
Support Forum
Hi henrique,
If we are talking about custom model class, then no, that's the only way.
If you want to add fields to the model of the store, then there is an option to use https://bryntum.com/docs/grid/api/Core/data/Store#config-fields
const store = new Store({
fields : ['name', 'city', 'company'],
data : [
{ id : 1, name : 'Mark', city : 'London', company : 'Cool inc' },
...
]
});
All the best,
Alex
When the Model class was written, JavaScript in our supported browsers did not support properties.
Now that it does, you can use a static property: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static
We no longer support IE.
This kind of syntax should work for you:
class TreeModel extends GridRowModel {
static fields = [
'Id',
'Name',
{ name : 'StartDate', dateFormat : 'YYYY-MM-DD' },
'Duration',
'PercentDone'
];
}