question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hearder filter search values in table.getAjaxUrl()

See original GitHub issue

Hi,

First of All thanks for this awesome Tabulator. I really love this.

I need a help on how to get current header search values in getAjaxUrl().

I’m generating custom url with ajaxUrlGenerator().

ajaxURLGenerator: function (url, config, params) {
        //url - the url from the ajaxURL property or setData function
        //config - the request config object from the ajaxConfig property
        //params - the params object from the ajaxParams property, this will also include any pagination, filter and sorting properties based on table setup
        params.offset = params.limit * (params.offset - 1);
        if (params.offset === 0) {
          delete params.offset;
        }

        const filters = params.filters;
        delete params.filters;

        let pagination = Object.keys(params).map(k => `${k}=${encodeURIComponent(params[k])}`).join('&');
        let search = filters.map(a => 'search=' + encodeURIComponent(a.field.toLowerCase() + ' eq ' + a.value)).join('&');
        search = search != '' ? '&' + search : search;
        this.fullAjaxUrl = url + "?" + pagination + search;
        console.log(this.fullAjaxUrl);

        //return request url
        return this.fullAjaxUrl; //encode parameters as a json object
      },

I need the url with search filters so that I can pass that to server for generating report. But this getAjaxUrl() gives only url as per docs. Please could you assist ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aklavercommented, Mar 14, 2019

Not from getAjaxUrl as far as I know. The only place I can find is this:

http://tabulator.info/docs/4.2/callbacks#ajax Ajax Request

The ajaxRequesting callback is triggered when ever an ajax request is made. var table = new Tabulator("#example-table", { ajaxRequesting:function(url, params){ //url - the URL of the request //params - the parameters passed with the request }, });

0reactions
fingers10commented, Mar 14, 2019

Let me make it clear. I’m generating a custom url with the search parameters in the URL as per my need. And that works fine and filters are applied in server and results are returned and displayed in tabulator.

My question - is it possible to retrieve the custom url which gets generated dynamically based on the my header search values? Tabulator anywhere storing this custom url?

I have url set in Ajax url property as https://...com/api/values

After applying header filter, now my url looks like https://...com/api/values?search=name eq some name

Let’s say like this is the last request made by tabulator to the server. Now if I call getAjaxUrl I’m getting the default url which is https://...com/api/values

Is it possible to get https://...com/api/search=name eq somename from getAjaxUrl method?

Am I clear now?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I filter my ajax result — DataTables forums
Use search to set the initial search to the desired department id. · Use the search() to search for the department id. ·...
Read more >
Jquery Datatables add search filter to header for a few ...
The DataTables columns() API function can be given a column selector. This can take various forms. One option is to provide an array ......
Read more >
How To Create a Filter/Search Table - W3Schools
Learn how to create a filter table with JavaScript. Filter Table. How to use JavaScript to search for specific data in a table....
Read more >
How to add Custom Filter in DataTable - AJAX and PHP
In this tutorial, I show how you can add the custom filter to the DataTable and use it for search record with jQuery...
Read more >
Datatables Individual column searching using PHP Ajax Jquery
How to make jquery Datatables individual column search or filter by using PHP script with Ajax. Video tutorial on Datatables individual ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found