Our blazing fast Grid component built with pure JavaScript


Post by gregc »

In your example pagination you have

store = new AjaxStore({
          readUrl         : '/pagedMockUrl',
        pageParamName   : 'page'
    });

and this generates a URL similar to

https://blah/pagedMockUrl?page=1&pageSize=100

however my URL already contains params e.g.

store = new AjaxStore({
          readUrl         : '/pagedMockUrl?myid=12',
        pageParamName   : 'page'
    });

and so now the URL generated is like

https://blah/pagedMockUrl?myid=12?page=1&pageSize=100

Is there a convenient way to pass my own parameters (defined at grid startup) to the URL?
Its not a big deal because I can work around it.

thanks!

Last edited by gregc on Mon Jan 11, 2021 7:15 pm, edited 1 time in total.

Post by mats »

Looks like a bug we should fix, what version are you using?


Post by gregc »

thats the nightly build


Post by pmiklashevich »

Please use the "params" config for your static params:

store = new AjaxStore({
    readUrl : '/loadWithParams',
    params : {
        foo : 'bar'
    }
});

We will make it public: https://github.com/bryntum/support/issues/2216

Also you can change the params dynamically in https://www.bryntum.com/docs/grid/#Core/data/AjaxStore#event-beforeRequest:

const store = new AjaxStore({
    readUrl   : '/loadWithParams',
    listeners : {
        beforeRequest({ params }) {
            Object.assign(params, { foo : 'bar' });
        }
    }
});

Cheers!

Pavlo Miklashevych
Sr. Frontend Developer


Post by gregc »

So the params config is nice but, it applies to every one of the CRUD URLs, and I have different parameters for each URL so I can't use it to replace my code.

I think the issue is that readURL (and the rest) shouldn't be constrained to have no parameters, its just if you add parameters, whether from the params config or pageSize, you should check to see if it already had ?blah=something and then add &foo=bar instead of ?foo=bar.

Again though, I have a work around for now.


Post by pmiklashevich »

Yes, this could be improved. Ticket here: https://github.com/bryntum/support/issues/2223

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply