bryntum / support

An issues-only repository for the Bryntum project management component suite which includes powerful Grid, Scheduler, Calendar, Kanban Task Board and Gantt chart components all built in pure JS / CSS / TypeScript
https://www.bryntum.com
53 stars 6 forks source link

Clarify Model.fields vs Model.allFields in docs #9700

Closed taauntik closed 1 month ago

taauntik commented 2 months ago

Forum post

Hi Team,

We have a requirement to add field to store/model dynamically based on record data. Used Core.data.Model#function-addField-static api but it is not working. Provided below sample. Request to review and provide a sample on how to add/remove fields from store/model dynamically.

follow the instructions below and observe in console after calling addField api, new field is not added to model.fields list

  1. open this demo https://bryntum.com/products/gantt/examples/basic/
  2. open up the console
  3. run this
    gantt.taskStore.modelClass.addField({ name : 'customField', defaultValue : 1, type : 'number' });
  4. Now check the fields list with gantt.taskStore.modelClass.fields
  5. And you'll see no new field added called customField
isglass commented 1 month ago

ModelClass.fields is the block that defines fields at that level in the prototype chain, not the full set of fields available. For that, use gantt.taskStore.modelClass.allFields.

Will clarify this in docs