Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

330
Visualizações
In Tabulator 5.0, how do you pass query parameters to ajaxResponse when calling setData?

I'm trying to make use of both the ajaxResponse and setData for a Tabulator 5.0 table. Somewhere my URL parameters are getting lost. In the following code the value for params is and empty object when logged to the console.

I'm using ajaxResponse because the portion of the response I need is in the "results". And I'm using setData because my intention is to repeatedly call it dynamically as my parameters change.

var table = new Tabulator("#my-tabulator-table", {
     ajaxResponse:function(url, params, response){
          console.log(url);
          console.log(params);
          return response.results;
     },
});

var columns = [
    {title:"id", field:"id", headerFilter:false, visible:true, download:true},
    {title:"field1", field:"field1", headerFilter:true, visible:true, download:true},
    {title:"field2", field:"field2", headerFilter:true, visible:true, download:true},
    {title:"field3", field:"field3", headerFilter:true, visible:true, download:true},
];
var url = "/api/v1/myendpoint";
var params = {"param_name": "abc"};

table.on("tableBuilt", function(){
     table.setColumns(columns);
     table.setData(url, params);
});

So how can I pass "params" so that they are combined with the url to make the proper ajax query call?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you are looking to make this request to load the initial data in the table then there is no need to call these functions at all, you can use the ajaxURL and ajaxParams options in the table constructor to automatically trigger the initial ajax request when the table loads

var table = new Tabulator("#example-table", {
    ajaxURL:"/api/v1/myendpoint, //ajax URL
    ajaxParams: {"param_name": "abc"},
});

You can also pass in your columns in a similar way using the columns option:

var table = new Tabulator("#example-table", {
    columns:[
        {title:"Name", field:"name", sorter:"string", width:200, editor:true},
        {title:"Age", field:"age", sorter:"number", hozAlign:"right", formatter:"progress"},
    ],
});

If you are looking to call the setData function at a later point, then you are calling it correctly in your example. There was a bug in the initial 5.0 release that prevented parameters being correctly set through the setData function, but that has been resolved in a sebsequent patch release.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda