Our state of the art Gantt chart


Post by jandresampaio »

Hi,

We're trying to adapt to the Bryntum Gantt, as we came from Ext versions...
In the previous versions we we're using uppercase properties like "Name" or "StartDate", and because our server sends us the date in this format it's not desirable for us to build mappings for the new "lowercase" Model classes...

So we're trying to use the "field" property in columns, like the following code, but as soon as we try to update the name in the row (by pressing enter), the previous value is kept and taskStore "changes" event is not triggered. I've noticed that if clicking on the header, the value sometime changes.

I've attached an Angular project for you to check.
We simply need that every change we make to this "alias" columns update the data behind and the UI...

    columns : [
        { type : 'name', field: "Name" },
        { type : 'startdate', field: "StartDate" }
    ] 
Thank you
Attachments
Bryntum-Gantt-Advanced.zip
(4.2 MiB) Downloaded 108 times

Post by Maxim Gorkovsky »

Hello.
You need to map record fields, not the columns. See Field data mapping section: https://bryntum.com/docs/gantt/#Common/data/Model#function-getDataSource
Smth like:
class MyTaskModel extends TaskModel {
  static get fields() {
    return [
      { name : 'startDate', dataSource : 'StartDate' }
    ];
  }
}

project = new ProjectModel({
  taskModelClass : MyTaskModel
});

Post by jandresampaio »

I tried that before but had this error:
core.js:6014 ERROR TypeError: Class constructor MyTaskModel cannot be invoked without 'new'
    at new ClassDefEx (gantt.umd.js:15341)
    at TaskStore.createRecord (gantt.umd.js:14644)
    at ProjectModel.ingestChildren (gantt.umd.js:19958)
    at ProjectModel.insertChild (gantt.umd.js:20265)
    at ProjectModel.appendChild (gantt.umd.js:20241)
    at TaskStore.set (gantt.umd.js:15485)
    at ProjectModel.loadInlineData (gantt.umd.js:67853)
    at ProjectModel.construct (gantt.umd.js:67827)
    at ProjectModel.construct (gantt.umd.js:41368)
    at ProjectModel.construct (gantt.umd.js:133049)
This is an Angular project (using typescript)

Post by Maxim Gorkovsky »

Are you importing classes from umd bundle? umd is used to support IE11 out of the box, you can use modules bundle instead if you don't need to support that.

Post by jandresampaio »

Same error when using modules bundle (typings and auto-imports do not work when using this module - with umd was not a problem...)...
You can check this on the attached project above by replacing the "bryntum-gantt/...umd" with "bryntum-gantt":
panel.component.ts:27 Uncaught (in promise) TypeError: Class constructor TaskModel cannot be invoked without 'new'
    at new MyTaskModel (panel.component.ts:27)
    at new ClassDefEx (gantt.module.js:29996)
    at TaskStore.createRecord (gantt.module.js:30319)
    at ProjectModel.ingestChildren (gantt.module.js:23450)
    at ProjectModel.insertChild (gantt.module.js:23913)
    at ProjectModel.appendChild (gantt.module.js:23882)
    at TaskStore.set data [as data] (gantt.module.js:30196)
    at ProjectModel.loadCrudStore (gantt.module.js:65497)
    at ProjectModel.loadDataToCrudStore (gantt.module.js:65530)
    at gantt.module.js:65558

Post by Maxim Gorkovsky »

I can reproduce this problem with the default settings. It can be fixed by changing buildTarget from 'es5' to 'es6'. Is this an option for you?

Post by jandresampaio »

Ok...regarding the original problem...we map the name field with the dataSource property, like:
class MyTaskModel extends TaskModel {
  static get fields() {
    return [
      { name : 'name', dataSource : 'Name' }
    ];
  }
}

Why does the name appear blank ?
Code attached
Attachments
Bryntum-Gantt-Advanced.zip
(8.38 MiB) Downloaded 125 times

Post by Maxim Gorkovsky »

Because in the data set which you use there's no `Name` fields, only `name`. Update key and it will be picked up.

Please do not include our sources to the test case, we only need to know version (1.1.5 in this case)

Post by jandresampaio »

The launch-saas.json has "Name" property in all the task rows...:
Name field in json.PNG
Name field in json.PNG (179.64 KiB) Viewed 2128 times

Post by Maxim Gorkovsky »

My bad, I confused different name fields.
I can see this problem in our advanced demo too, I opened a ticket: https://app.assembla.com/spaces/bryntum/tickets/9389-cannot-set-datasource-to-name-field-in-task-model/details
Thank you for report!

Also overriding Id field should be like this:
class MyTaskModel extends TaskModel {
  static get fields() {
    return [
      { name : 'Id' }
    ];
  }
}

MyTaskModel.idField = 'Id';

Post Reply