Page 1 of 1

[ANGULAR] - Can we update only changes from the new complete JSON?

Posted: Thu Feb 18, 2021 7:36 am
by raju1

Hi,

Currently we are sending the JSON data to the ProjectModel using loadInlineData and using our own engine calculations to update the JSON such that whenever a change is made, we generate the new JSON and replace the ProjectModel. The downside with this approach is that there is a lot of waiting time for any change.
Is it possible to compare the changes between the 2 JSON objects and only apply the changes rather than the whole project?

Thanks,
Nagaraju


Re: [ANGULAR] - Can we update only changes from the new complete JSON?

Posted: Thu Feb 18, 2021 9:50 am
by alex.l

Hi Nagaraju,

Please check this: https://bryntum.com/docs/gantt/#Core/data/mixin/StoreSync#config-syncDataOnLoad

Configure with true to sync loaded data instead of replacing existing with a new dataset.

Also we have Dynamic Response Type which may be enabled using https://bryntum.com/docs/gantt/#Scheduler/crud/AbstractCrudManagerMixin#config-trackResponseType that allows to manage response type. After set it on true, use https://bryntum.com/docs/gantt/#Gantt/model/ProjectModel#function-loadCrudManagerData to load your data. Be aware to update response object format as it described in our guide: https://bryntum.com/docs/gantt/#guides/data/crud_manager.md#loading-data
Example:

{
        "success"     : true,
        "requestId"   : 123,
        "type"      : "sync",
        "revision"    : 5,

    "books"       : {
        "rows" : [
            { "id" : 65, "title" : "War and Peeace", "published" : 1826, "added_dt" : "2019-01-01T00:00:00", "updated_dt" : null },
            { "id" : 9000, "title" : "The Last of the Mohicans", "published" : 1869, "added_dt" : "2019-01-01T00:00:00", "updated_dt" : null },
            { "id" : 9001, "title" : "The Last of the Mohicans", "published" : 1869, "added_dt" : "2019-04-25T13:56:17", "updated_dt" : null }
        ],
        "metaData" : {
            "most-popular-book-id" : 9000
        },
        "total" : 5
    },

    "writers"      : {
        "rows" : [
            { "id" : 1, "name" : "Leo", "surname" : "Tolstoy" },
            { "id" : 2, "name" : "James Fenimore", "surname" : "Cooper" }
        ],
        "total" : 2
    },

    "authors"      : {
        "rows" : [
            { "id" : 1, "book_id" : 65, "writer_id" : 1 },
            { "id" : 2, "book_id" : 9000, "writer_id" : 2 },
            { "id" : 3, "book_id" : 9001, "writer_id" : 2 }
        ],
        "total" : 2
    }
}

The guide is here: https://bryntum.com/docs/gantt/#guides/data/crud_manager.md#dynamic-response-type

All the best,
Alex


Re: [ANGULAR] - Can we update only changes from the new complete JSON?

Posted: Thu Feb 18, 2021 4:36 pm
by raju1

Hi Alex,

Thanks for the reply, The solution is working quite well, but we are facing the same problem as in this post: viewtopic.php?f=51&t=15922

I have set repopulateOnDataset : false, and the error still persists.
On checking gantt.umd.js, I found that the property 'repopulateOnDataset' is set as 'repopulateOnDataSet' (Capital "S"). Updating this property prevented the errors.

repopopulateDatset.png
repopopulateDatset.png (407.57 KiB) Viewed 1873 times

After changing this, syncDataOnLoad works very well for taskStore:

this.gantt.project.taskStore.data = this.bryntumService.bryntumTree.tasks.rows;

but it causes a crash for the other stores:

this.gantt.project.dependencyStore.data = this.bryntumService.bryntumTree.dependencies.rows;
this.gantt.project.resourcesData.data = this.bryntumService.bryntumTree.resources.rows;
this.gantt.project.assignmentsData.data = this.bryntumService.bryntumTree.assignments.rows;

Is there a specific change to be given for the other stores?

Thanks,
Nagaraju


Re: [ANGULAR] - Can we update only changes from the new complete JSON?

Posted: Thu Feb 18, 2021 5:01 pm
by saki

Re: [ANGULAR] - Can we update only changes from the new complete JSON?

Posted: Fri Feb 19, 2021 8:46 am
by raju1

Hi,

Would the upcoming Gantt 4.1.0 release contain the property change from "repopulateDataSet" to "repopulateDataset" (Capital "S")?

Thanks,
Nagaraju


Re: [ANGULAR] - Can we update only changes from the new complete JSON?

Posted: Fri Feb 19, 2021 5:16 pm
by pmiklashevich

We will fix that. Thank for pointing out!