Page 1 of 1

[REACT] Tracking changes for fields which are array

Posted: Mon Jul 26, 2021 12:49 pm
by Bhava

Hi team,
I have data as below:

  "newarray": [
                  {
                    "id": 1,
                    "from": "PHO",
                    "to": "MNL",
                  },
                  {
                    "id": 2,
                    "from": "MNL",
                    "to": "AHM"
                  }
                ]       
MicrosoftTeams-image (20).png
MicrosoftTeams-image (20).png (110.38 KiB) Viewed 622 times

How i can create a store just like baselines in the above screenshot


Re: [REACT] Tracking changes for fields which are array

Posted: Mon Jul 26, 2021 4:51 pm
by saki

There is currently no automated or configurable way of creating user-defined 1:many stores in a model. Baselines are created automatically by the Gantt component. You could create such store manually though, populating it with the data from the json response.

I have created a feature request: https://github.com/bryntum/support/issues/3222


Re: [REACT] Tracking changes for fields which are array

Posted: Mon Jul 26, 2021 9:09 pm
by Bhava

thank you


Re: [REACT] Tracking changes for fields which are array

Posted: Sun Aug 07, 2022 8:58 pm
by pmiklashevich

I've found a part of the code where you define the relation:

lib/Scheduler/model/ResourceTimeRangeModel.js

    static get relationConfig() {
        return [
            /**
             * The associated resource, retrieved using a relation to a ResourceStore determined by the value assigned
             * to `resourceId`. The relation also lets you access all time ranges on a resource through
             * `ResourceModel#timeRanges`.
             * @member {Scheduler.model.ResourceModel} resource
             */
            { relationName : 'resource', fieldName : 'resourceId', store : 'resourceStore', collectionName : 'timeRanges', nullFieldOnRemove : true }
        ];
    }

It would be nice if you can make this public. Thanks.


Re: [REACT] Tracking changes for fields which are array

Posted: Mon Aug 08, 2022 12:42 pm
by alex.l

Hi Pavel,

Could you please describe why do you want this public?


Re: [REACT] Tracking changes for fields which are array

Posted: Mon Aug 08, 2022 2:24 pm
by pmiklashevich

Hi Alex,

I have lots of related models. For example, I have Group Store, which looks like:

{
  id : 1,
  title : 'Forwards',
  players: [
    { id : 1, name : 'Kylian Mbappe' } ,
    { id : 2, name : 'Lionel Messi' },
    { id : 3, name : 'Neymar' }
  ],
}

So it's obvious there is a Players Store holding info of all players, and there is a Groups store, which organises players in some groups, i.e. Forwards. Every group has "players" field which would be nice to have turned into a Store of Records instead of simple array of objects.

Please suggest the best way to achieve this.


Re: [REACT] Tracking changes for fields which are array

Posted: Thu Aug 11, 2022 11:48 am
by alex.l

Ok, I see. So you need it for Model, not for ResourceTimeRange :). That's clear now.
We have a ticket for that https://github.com/bryntum/support/issues/3222
I will notify about your request to raise the priority.