Our flexible Kanban board for managing tasks with drag drop


Post by rodel.ocfemia »

Hi,
I need to pass a json payload to the transport load. The example below will pass the foo as part of the querystring. I cannot pass the json through querystring because sometimes it can become large.

load : {
        url       : 'https://mycool-server.com/load.php',
        // HTTP request parameter used to pass serialized "load"-requests
        paramName : 'data',
        // pass extra HTTP request parameter
        params    : {
            foo : [{data: 'data1'},{data:'data2'}]
        }
    },

In Jquery, something like this.

$.service('url', {
         model: [{data: 'data1'},{data:'data2'}],
         returnType: 'text'
      }).done(function (response) {
         
});

Post by mats »

This is currently being fixed, but for now you can use this workaround, let me know if that solves it for you. Docs: https://bryntum.com/docs/gantt/api/Scheduler/crud/transport/AjaxTransport#event-beforeSend

 project : {
        autoLoad  : true,
        transport : {
            load : {
                url    : '../_datasets/launch-saas.json',
                method : 'POST'
            }
        },
        listeners : {
            beforeSend({ requestConfig }) {
                requestConfig.body = JSON.stringify({ ...JSON.parse(requestConfig.body), foo : 1 });
            }
        }
    },

Or if it's static data you want to pass:


project : {
    autoLoad : true,
    encoder  : {
        requestData : {
            foo : 'Bar'
        }
    },
    transport : {
        load : {
            url : '../_datasets/launch-saas.json'
        }
    }
},

Post by rodel.ocfemia »

Thanks mats. It worked.


Post Reply