Page 1 of 1

[REACT] Change duration unit

Posted: Thu Dec 01, 2022 9:09 am
by hien.nguyen

Hi team,

I got problem about change duration unit, I can change it to hour by return data from api and add property durationUnit = hour ==> this setting is OK for old task.

1.png
1.png (54.11 KiB) Viewed 660 times

Problem happen on add new task: duration unit back to day. Please share me the way to set it to hour

2.png
2.png (29.55 KiB) Viewed 660 times

Re: [REACT] Change duration unit

Posted: Thu Dec 01, 2022 12:12 pm
by marcio

Hey hien.nguyen,

You'll need to extend the default TaskModel and update the default value of durationUnit field
https://bryntum.com/products/gantt/docs/api/Gantt/model/TaskModel#field-durationUnit

class MyTaskModel extends TaskModel {
    static get fields() {
        return [
            { name : 'durationUnit', defaultValue: 'hour' }
        ];
    }
}

And then update your project configuration

const
    project = new ProjectModel({
        taskModelClass : MyTaskModel,
        // ...other configurations

or inside your Gantt configuration

 gantt = new Gantt({
        appendTo : 'container',
        project  : {
        taskModelClass : MyTaskModel,
        // ...other configurations
 

Re: [REACT] Change duration unit

Posted: Fri Dec 02, 2022 3:37 am
by hien.nguyen

Yes,

It's ok but I got new problem: horizontal bar will disappear after I add taskModelClass into project

project = new ProjectModel({
        taskModelClass : MyTaskModel,

It's related to https://github.com/bryntum/support/issues/5512.

Have debugged with @JockeLindberg, and it seems to be doing what it should. Closing ticket as invalid

It mean: no need to fix anything?

BTW, current I used version 5.1.5. Now I need to upgrade to 5.2.4 for fix this bug?


Re: [REACT] Change duration unit

Posted: Fri Dec 02, 2022 6:58 am
by alex.l

Hi hien.nguyen,

When you change default value for TaskModel, all duration values will be interpreted as value in new durationUnit units, if these tasks doesn't have own value in record data.

BTW, current I used version 5.1.5. Now I need to upgrade to 5.2.4 for fix this bug?

No, the team decided this is expected behaviour.


Re: [REACT] Change duration unit

Posted: Fri Dec 02, 2022 7:02 am
by hien.nguyen

Yes,

durationUnit is OK, but new problem I got about: horizontal bar not display?

My problem related with above git issue #5512 and detail in topic viewtopic.php?t=20176


Re: [REACT] Change duration unit

Posted: Mon Dec 05, 2022 3:07 am
by hien.nguyen

Hi team,

I still have problem with no horizontal bar, please help me.


Re: [REACT] Change duration unit

Posted: Mon Dec 05, 2022 6:43 am
by alex.l

horizontal bar not display?

Do you have something to scroll? I see full project is displayed on the viewport, so nothing to scroll, that's why no scrollbar appeared.
Does it look different for you?

Please check recommendations from this post, if you want to always have a scrollbar viewtopic.php?p=112846#p112846

Let us know if it helped or not.