Tabulator: setting page in ajaxParams

Created on 13 Mar 2017  Â·  16Comments  Â·  Source: olifolkerd/tabulator

Hi Oli, I'm trying to "setData" forcing the page number to display, but Tabulator keeps replacing my page with 1.

To reload I'm using:

tabulator("setData", ajaxURL, ajaxParams);

Where ajaxURL us the URL I'm calling and ajaxParams is:

{
    page: "3",
    format: "json"
}

It should generate an URL similar to ?format=json&page=3, but it's generating ?format=json&page=1.

Question - Ask On Stack Overflow

All 16 comments

I'm trying to implement a reload data without altering the params passed in a previous request.

Hey,

Could you post a copy of your Tabulator constructor object so i can see what you are trying to achieve?

if you are trying to pull down a specific page then i would suggest using the setPage function instead:

$("#example-table").tabulator("setPage", 5);

Let me know if that helps,

Cheers

Oli

Well, that retrieves the page 5, but ignores my other ajaxParams.

Ahh I see your problem,

You are making custom alterations to a pagination ajax request. you can pass static parameters along with the pagination request using the ajaxParams property:

$("#example-table").tabulator({
    pagination:"remote", //enable remote pagination
    ajaxURL:"http://testdata.com/data", //set url for ajax request
    ajaxParams:{format:"json"}, //set any standard parameters to pass with the request
});

Cheers

Oli

Yes, of course I'm doing that!.

So, after setting ajaxParams, instead of calling "setData" I should just call "setPage"?

Yes that is correct :)

Excelent!, that worked!.

Sorry Oli, I was too quick to answer, but sadly it does not work.

Basically I'm doing this:

var currentPage = table.tabulator("getPage");
var ajaxParams = table.tabulator("option").ajaxParams;
ajaxParams.idstatus = currentStatus.idstatus;
ajaxParams.format = "json";
table.tabulator("setPage", currentPage);

But the only parameter changed is page, when also idstatus should change (currentStatus.idstatus IS changed).

Hi again Oli, the solution was (as usual) first read the docs!, then use a custom paginator.

Sorry, when I call tabulator("setData") the paginator is called without pageNo and ajaxParams. What I want to do is to refresh the server side data without changing the last URL.

You shouldn't need to call setData, just set the page again with setPage and that will do it for you if you are using the custom paginator.

Could you post a copy of your Tabulator constructor object and the functions you are using to trigger the refresh so i can replicate the issues you are having.

Cheers

Oli

Hi again Oli, I don't know if this is a bug, it certainly looks like one ;-), but I found sorting params are not passed to the custom paginator. Where can I query for those?, to create the returned url including sort fields.

Hey,

As the sort and filter functions are performed locally they are not passed directly to the custom paginator.

If you want the sort object, you can use the getSort function:

var sorter = $("#example-table").tabulator("getSort");

Let me know if that helps.

Cheers

Oli

How can i set the page BEFORE a request is made? I need to recreate a remote table with the same filters and at the same page when the user navigates back to it. When i create a new Tabulator object, is instantly fires a request with page 1, even if i change the page parameter using the ajaxParams object.

You can't manually alter the state of the page it is handled internally by
the table. It will be overwritten if you try and manipulate it using the
Ajax Params.

If you call the setPage function after the table is built, in one or the
callbacks, then that will set the page for u

Cheers

Oli

On Wed, 23 Oct 2019, 03:38 Diego Victor de Jesus, notifications@github.com
wrote:

How can i set the page BEFORE a request is made? I need to recreate a
remote table with the same filters and at the same page when the user
navigates back to it. When i create a new Tabulator object, is instantly
fires a request with page 1, even if i change the page parameter using the
ajaxParams object.

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/olifolkerd/tabulator/issues/217?email_source=notifications&email_token=ABUGBTCKJYRJJWXS62RDQJLQP62KTA5CNFSM4DDNXS22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEB72Y7I#issuecomment-545238141,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABUGBTEIIH3SOIJVZ2763PLQP62KTANCNFSM4DDNXS2Q
.

Hello Oli. So i could listen for the tableBuilt event and then set a page inside it and that event would not be called again?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yaxino picture yaxino  Â·  3Comments

mconnelley picture mconnelley  Â·  3Comments

andreivanea picture andreivanea  Â·  3Comments

Honiah picture Honiah  Â·  3Comments

KES777 picture KES777  Â·  3Comments