Premium support for our pure JavaScript UI components


Post by NARESH.RAI »

Hi,

How could i get json data for -
1) task assigned for particular Resources?
2) dependencies
3) calendar
same as taskStore which we can import again in gantt component


Post by saki »

  1. filter the task store first, for example with:

    taskStore.filter({property:'resourceId', id:'a', value:2})

    and then you can use taskStore.json to get the data.

  2. you can get it using scheduler.dependencyStore.json

  3. calendars are supported by SchedulerPro and Gantt and there you can use project.calendarManagerStore.json


Post by NARESH.RAI »

#1 - Not worked for me, is there any example ? so i will be easy for understanding.
#2 - Need gantt chart dependency, how we can use scheduler.dependencyStore.json ?
can u please provide more details?


Post by saki »

#1 post please a showcase, I've tested it and it worked here so there must be something different
#2 it is same for gantt: gantt.dependencyStore.json


Post by saki »

I have tried to find a better way how to get json of "events/tasks assigned to a resource" and there is one.

For SchedulerPro it would be to get a resource record and then access events property. You can test it at https://www.bryntum.com/examples/scheduler-pro/constraints/ by typing in console:

JSON.stringify(bryntum.query('schedulerpro').resourceStore.getAt(8).events);

This takes the resource with 2 tasks assigned.

For Gantt, the procedure is same but the property name is tasks. You can test it at https://www.bryntum.com/examples/gantt/advanced with:

JSON.stringify(bryntum.query('gantt').resourceStore.first.tasks) // tasks assigned to "Celia"

You can also test json data of dependencies on the same URL with:

bryntum.query('gantt').dependencyStore.json

Mind please that if we need data from a store then we can use its property json but when we have an array of records (such as events or tasks above) we need to use JSON.stringify as JavaScript arrays do not have json property.


Post by NARESH.RAI »

Hello Saki,

I am able to get data for Resources & dependencies but same data if import in gantt its not working.

I after analysis found this.

when i export json -

 this.gantt.ganttInstance.project.dependencyStore.json 

I get object ->

{
                "id"        : 1,
                "fromTask" : {id:'1', name:'test'},
                "toTask"   : {id:'2', name:'test'},
                "lag"      : 2
            },

but gantt recognized this object only in below format when we import->

{
                "id"        : 1,
                "fromTask" : 45,
                "toTask"   : 4,
                "lag"      : 2
            }

Any solution this ?


Post by alex.l »

Hi NARESH.RAI,

That looks weird. I was not able to reproduce it. To help you out with that we need a runnable test case. Also please let us know a version of Gantt you are using.
Could you please modify one of our examples and and attach it here? It may not be an Angular app, just keep it as simple as you can.

All best,
Alex

All the best,
Alex


Post by fabio.mazza »

Hi Naresh,

I also tested on our Gantt/examples/angular/advanced (see image) and I get Id values from fromTask and toTask . As you can see, I called .json method on load of the project. Could you confirm what was the moment that you get this object on these fields to be able to reproduce?

Screen Shot 2020-10-05 at 14.49.03.png
Screen Shot 2020-10-05 at 14.49.03.png (332.76 KiB) Viewed 1498 times

Thank you!

Best regards,
Fabio


Post by NARESH.RAI »

Hi,

Yes, it's working in Gantt examples as there component initially load data from /assets/data.json with same format.
but when u create new project dynamically then it will export different json format.

Follow below steps to reproduce in any angular example -
Create new project model on button click -

1)

 this.project = new ProjectModel();
  this.project.startDate = '2020-12-01';
  this.gantt.ganttInstance.startDate = new Date('2020-12-01');

2) pass "project" variable to gantt component ->

<bry-gantt
  #gantt
  [height]="ganttConfig.height"
  [startDate]="ganttConfig.startDate"
  [columns]="ganttConfig.columns"
  [project]="project"
  </bry-gantt>
  

3) now add new task with dependency
4) Now check -> this.gantt.ganttInstance.project.dependencyStore.json

u will get different format for json (which i have mentioned before)
check attachment

let me know if u have any queries.

Thanks.

Attachments
jsonStore.JPG
jsonStore.JPG (39.61 KiB) Viewed 1496 times

Post by NARESH.RAI »

When i import json data into gantt and try to add new task getting error attached

gantt-save.JPG
gantt-save.JPG (34.82 KiB) Viewed 1494 times

.

Its about Id duplication of task. (getting this error only for new task when we import data from json)


Post Reply