Our state of the art Gantt chart


Post by MauriceLapre »

Hi,
I'm trying to implement my own crudmanager to have more control of getting data and manipulating response (as I can't modify the JSON response of the server) before sending it to the stores. I believe that should be possible via "beforeloadapply" or "beforeresponseapply", right?
So, I've created a simple crudmanager:
var crudManager = new CrudManager({
    autoLoad        : true,
    resourceStore   : myResourceStore,   
    eventStore      : myTaskStore,
    assignmentStore : myAssignmentStore,    
    dependencyStore : myDependencyStore,
    ...
    
No transport, as I want to define ajax calls separate in all of the stores. Stores are created before the crudmanager, with readUrl etc.
let myResourceStore = new ResourceStore({
    id : 'resources',
    modelClass      : SpsResourceModel,
    ...
But on loading I get this error:
Bryntum Gantt - 004.png
Bryntum Gantt - 004.png (28.35 KiB) Viewed 2177 times
Am I doing something wrong with either the crudmanager or the resourcestore?

Post by MauriceLapre »

I tried some things in the mean time, and think I can manage the same with "beforeAdd" listener on the store? Because you can block it by returning false. So, capture response from server, modify the data and use .add on the store and return false for the function. One thing though, project grid is not updated, even when adding project.propagate()...

Any thoughts on the matter would be nice :)

Post by sergey.maltsev »

Hi!

Could you please attach here an example which we can run and check?
It would be good if you make it on basis of one of our demos.

Post by MauriceLapre »

I've made this based on the Advanced Demo, see attached code. Get the same error as I get on my own similar code.
Attachments
app.module-435564.js
(30.2 KiB) Downloaded 126 times

Post by arcady »

ProjectModel class itself is a CrudManager instance (since GanttCrudManager mixin is applied to the class).

So no need to make a new instance just use project model itself:
const project = new ProjectModel({

    taskStore       : myTaskStore,
    resourceStore   : myResourceStore,
    assignmentStore : myAssignmentStore,
    dependencyStore : myDependencyStore,

    listeners: {
        beforeloadapply: function(h, i, j) {
            console.log('beforeloadapply');
            console.log(h);
            console.log(i);
            console.log(j);
        },
        beforeresponseapply: function(k, l, m) {
            console.log('beforeresponseapply');
            console.log(k);
            console.log(l);
            console.log(m);
        }
    },
    ...

Post by MauriceLapre »

Removed the new instance and got it working, thanks! Only beforeloadapply and beforeresponseapply are not fired because I'm not using load on the project, but on the stores independantly.

Although it works, the tasks are not shown after all loading is completed, even with calling project.propagate() after load. The tasks are there because when I initiate a search in the filter bar, they show up. How can I refresh the Gantt after loading so the tasks show up?

Post by arcady »


Post by MauriceLapre »

That didn't work, but renderRows() (and renderContents() too) did work.

Getting an error on the load of the ResourceStore now... beforeAdd does not seem to fire, like it does on the TaskStore...

TypeError: data.some is not a function
at ResourceStore$1.set data [as data] (gantt-1.1.5/build/gantt.module.js:30185:82)
at gantt-1.1.5/build/gantt.module.js:37458:21
at gantt.module.js:37397:29

Post by pmiklashevich »

Could you please provide your final version as a runnable testcase so we can take a look? And add some steps to reproduce. Thanks!

Pavlo Miklashevych
Sr. Frontend Developer


Post by MauriceLapre »

Code is looking something like this, based on Advanced demo again (and version 1.2.0). If you correct urls for data loading, then you should get the error as I stated in previous post.
Thanks!
Attachments
app.module_436952.js
(31.23 KiB) Downloaded 135 times

Post Reply