Discuss anything related to web development but no technical support questions


Post by sandippatel »

Hello

I am trying to pass the parameter dynamically to load the data from database for certain period or for specific project id. I use Project store's load method for that following are screenshot for the same.

load issue.PNG
load issue.PNG (14.99 KiB) Viewed 3362 times

so there are 2 questions:

1) Here the I am not passing anything in paramname 'q' still it pass some data to the api. so in which scenario I could use this paramname?
2) I want to pass "id" as a dynamic parameter mention in "params" parameter. so would it be possible?

I am following this documentation to generate my scenario

https://bryntum.com/docs/gantt/#Scheduler/data/CrudManager

Thanks for the help.


Post by saki »

To send a param dynamically you need to listen to https://www.bryntum.com/docs/gantt/#Gantt/model/ProjectModel#event-beforeSend event and set the new value for the param in the listener. You can test it in Gantt basic example with this code:

let id = 111;

const project = new ProjectModel({
    transport : {
        load : {
            url : '../_datasets/launch-saas.json',
        }
    },
    listeners : {
        beforeSend : ({ params }) => {
            params.id = id;
        }
    }
});

Post by sandippatel »

Thanks for the reply

I've tried this solution but seems it did not work or I used wrongly.

Here what I did.

1) I have passed parameter dynamically when define "Panel"
2) After that assigned value to the variable
3) passed the assign value to ganttconfig so I could pass it in query from front-end to back-end

Please see below images

1st Step
1st Step
1.PNG (6.73 KiB) Viewed 3346 times
2nd Step
2nd Step
2.PNG (10.5 KiB) Viewed 3346 times
3rd Step
3rd Step
3.PNG (28.43 KiB) Viewed 3346 times

Post by alex.l »

Hi sandippatel,

I don't see you set a valid value to your actionId variable in your last screenshot, only initial null. I don't see you used ganttConfig.actionId that you set above.
Try to use the next code in your beforeSend method:

params.id = 'test';

If it'll be passed to the server, when all is ok with the Gantt and you need to debug your application.

All best,
Alex

All the best,
Alex


Post by sandippatel »

I have tried this solution but still the value I have set in

params.id = 'test';

does not passed to server.


Post by alex.l »

Hi sandippatel,

I tested it with our examples and it works well to me. Could you please try to reproduce this problem with our demo examples?
What version of Gantt do you use? I checked with latest 4.0.3. Try to update if you used an older one.
Please review docs, maybe it helps to find the problem:
https://bryntum.com/docs/gantt/#Scheduler/crud/transport/AjaxTransport#config-transport
https://bryntum.com/docs/gantt/#Scheduler/crud/transport/AjaxTransport#event-beforeSend

This config works to me:

const project = window.project = new ProjectModel({
    autoLoad  : true,
    autoSync  : true,
    transport : {
        load : {
            url : '../_datasets/criticalpaths.json',
            params : {
                id : 1
            }
        },
        sync : {
            url : '../_datasets/criticalpaths.json',
            params : {
                id : 1
            }
        }
    },
    listeners : {
        beforeSend({ params }) {
            params.hello = 22;
        }
    }
});

All best,
Alex

All the best,
Alex


Post by sandippatel »

Thanks for your support.

My problem is I am trying to pass the value of Id from another component and it failed. that what I posted first time.


Post by alex.l »

Hi sandippatel,

I understand your problem, but unfortunately we do support only our source code and not user apps.
Try to debug your application, check if your variable is exists at the moment of set params. Check scopes you used to define your variable. Very possible your variable is available in gantt.actionId as far as I can see in your code, but I cannot be sure 100%.

Good luck!
Alex

All the best,
Alex


Post by sandippatel »

Thanks Alex.

Finally I found the way. thank for your kind help


Post Reply