Our state of the art Gantt chart


Post by ggalipeau »

We are attempting to use the Bryntum Gantt Chart to save data to a Project Online backend. We have 99% working. The one issue we have is order of tasks when they are added or moved around.

We looked at the schema that is passed up and see the parentid and parentindex. So, obviously the index is suppose to be used to figure out the sort order. However, our backend datastore has a concept called AddAfterID. So, I really need the ID of the task that is right before the one I am adding or moving around.

I got it working on the server side. But, it causes a performance hit because I have to load my project in memory on the server just to get the previous ID. We already have a performance hit (because Project Online is slow).

So, my question is this - is there anyway to inject information into the sync before I send it to the server? Or, is there anyway to catch adds and moves in the task store and do client side manipulation? Basically, I have the ID of the Task before the one I am modifying in the Bryntum Gantt on the client side already. I just want to pass that ID up with the sync instead of the parentidex. Any clever events I can capture to help with this is much appreciated.

Basically, would love to pass up:

{tasks: {
   "added": [{
       parentid: "1234",
       addAfterid: "5678"
     }]
   }
}

Instead of

{tasks: {
   "added": [{
       parentid: "1234",
       parentIndex: 3
     }]
   }
}

Thanks,
Greg


Post by mats »

Easy to solve using the https://bryntum.com/docs/gantt/#Gantt/model/ProjectModel#event-beforeSync event, where you can modify the data sent.

listeners : {
         beforeSync({ pack, source : crudManager }) {
                const updated = pack.tasks.updated,
                           taskStore = crudManager.taskStore;
                updated.forEach(taskData => // do something with task data )
            }
        },
        

Post Reply