Our state of the art Gantt chart


Post by foursite »

Hello,

I am trying to add columns to Gantt dynamically. I cannot manage to use a field when it nested values.
In the current scenario, I have a metas property on my model, but struggling to reach nested keys as the field name.

Am I missing something? Or do I need to loop over my data and carry rate and currency on one upper level? The keys under metas are populated by the user, so I cannot add it manually on the config file.
"metas": {
		"rate": {
			"id": 32,
			"value": 5
		},
		"currency": {
			"id": 1234,
			"value": "gbp"
		}
},
            let meta =   { field : 'metas.rate', text: 'Rate', renderer({ item }) {
                    if( item ){
                        return `${item.value}`
                    }
                    return 0
                } };
            ganttConfig.columns.splice(ganttConfig.columns.length-1,0,meta);
Also, even if I move all metas, then I am not sure how to dynamically update ganttConfig to make these fields interactive.
class MyTaskModel extends TaskModel {

    static get fields() {
        return [
		{ field: 'rate',  type : 'number' }
        ];
    }
}

Post by mats »

It should work just fine, can you please produce a small test case for us so we can try to debug this?

Post by foursite »

Thanks for your reply @mats!

I moved all to level 0 elements now, maybe it's not a bug, so I don't want to take your time on it.

The code below works,
           
            let meta =   { field : 'rate', text: 'Rate', renderer({ item }) {
                    if( item ){
                        return `${item.value}`
                    }
                    return 0
                } };
            ganttConfig.columns.splice(ganttConfig.columns.length-1,0,meta);


You see I've found this example; https://www.bryntum.com/examples/gantt/aggregation-column/ and this one https://www.bryntum.com/examples/grid/columns/
The second one is exactly what I am trying to do but not sure if this is good for Gantt.
If I could figure out how to generate the following bit dynamically looks like I'll be done.
class MyTaskModel extends TaskModel {

    static get fields() {
        return [
		{ field: 'rate',  type : 'number' }
        ];
    }
}
Note: Using Gantt v 2.1.0

Post by mats »

The second one is exactly what I am trying to do but not sure if this is good for Gantt.
Yes it is, Gantt is a subclass of Grid. You can add fields to the Model at runtime too. https://bryntum.com/docs/scheduler/#Core/data/Model#function-addField-static

Post by foursite »

Hello @mats, I decided to prepare a test case as I cannot still manage to read nested items. Thought to move all items as first-level keys would sort my issue but then this creates a huge backend processing for me.


Sharing my screen so you can actually see it is not loading once I use nested fields
https://www.loom.com/share/a24b44e080bb412488f8102784bf6cc8

Thank you!

Post by sergey.maltsev »

Hi, foursite!

Did you manage to prepare a sample code for us to show the problem?
Please attach it here so we could check it.

Post Reply