Search code examples
javascripttabulator

Desired page in pagination with Tabulator


I am using Tabulator, I need to add input box that takes you to a desired page. If you have 10 pages and you want to go to page 9 you would just input 9 and hit enter. This feature is available in DataTables here is an example so how to do this with Tabulator? thank you


Solution

  • http://tabulator.info/docs/4.6/page#manage

    You would need to use the table.setPage(x) function where table is your Tabulator instance and x is the page number you want to go to.

    So here is an example of what the event listener function would look like on one of your elements.

    function pageListener(event){
      if (isNaN(event.target.value)){
        // We don't want anything that isn't a number.
        return;
      }
      // Assuming that 'table' is a variable containing the
      // Tabulator instance
      table.setPage(Number(event.target.value));
    }
    

    And here is a working example. https://jsfiddle.net/nrayburn/fewqhuar/1/