Our pure JavaScript Scheduler component


Post by sisco »

I'm wondering how to pass some extra parameters in the body to a POST query.

This is my extra parameters

   date: "2021-03-29T00:00:00",
                                 ueIdentifiers: ["UE751"],
                                 selectedView: "resources_view" 

For example:

  
crudManager : { autoLoad : true, transport : { load : { url: 'https://localhost:3100/api/TaskGanttApi/LoadNgResourceView', method: 'POST', params: { date: "2021-03-29T00:00:00", ueIdentifiers: ["UE751"], selectedView: "resources_view" }, } }

today i ve got this.

  
type: "load", requestId: null,…} requestId: null stores: ["events", "resources", "assignments", "dependencies", "resourceTimeRanges", "timeRanges"] type: "load"

Post by alex.l »

HI sisco,

Looks like you used the correct property.
Full docs about transport configuration may be found here: https://www.bryntum.com/docs/scheduler/#Scheduler/crud/transport/AjaxTransport#config-transport
If you have problems, please share your app here, we will be able to ran it and debug. Our support policy is here: viewtopic.php?f=35&t=772

All the best,
Alex

All the best,
Alex


Post by sisco »

If i set

 method: 'POST',
                             params: {
                                 date: "2021-03-29T00:00:00",
                                 ueIdentifiers: ["UE751"],
                                 selectedView: "resources_view"
                             },
                             

The result is not what i'm expected. Indeed, params are passed by the url and not in the body.

If i do this :

 body: JSON.stringify({
                                 date: "2021-03-29T00:00:00",
                                 ueIdentifiers: ["UE751"],
                                 selectedView: "resources_view"
                             })

my body is overrided by your method :

{"type":"load","requestId":null,"stores":["events","resources","assignments","dependencies","resourceTimeRanges","timeRanges"]}

Post by pmiklashevich »

Please listen to beforeLoad event and modify "pack" object. The pack object is generated dynamically based on the store changes. Whatever you add there will be added to the body automatically. For example:

new Scheduler({
    crudManager : {
        listeners : {
            beforeLoad({ pack }) {
                Object.assign(pack, {
                    date: "2021-03-29T00:00:00",
                    ueIdentifiers: ["UE751"],
                    selectedView: "resources_view"
                });
            }
        },
        transport : {
            load : {
                url: 'php/read.php',
                method: 'POST'
            },
            sync : {
                url : 'php/sync.php'
            }
        },

    autoLoad      : true,
    autoSync      : true,

Another option is to disable autoLoad and pass an object to the load function:

scheduler.crudManager.load({
    date          : '2021-03-29T00:00:00',
    ueIdentifiers : ['UE751'],
    selectedView  : 'resources_view'
});

Pavlo Miklashevych
Sr. Frontend Developer


Post by pmiklashevich »

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply