jumpToData question

jumpToData question

Dane JurkovicDane Jurkovic Posts: 12Questions: 6Answers: 0

As always I would like to thank anyone fist that helps me out with this....

Is there an easy way to get a page number then I am doing here in this jsfiddle example?

My example is a two set process in that I have to fist set the page then query it to find the page number. Is there a one step process that does this?

Thanks again...

Answers

  • kthorngrenkthorngren Posts: 20,145Questions: 26Answers: 4,736

    Do you mean something like this? $('#xCPN').val(table.page.info().page);

    Example:
    https://jsfiddle.net/h86m7qLr/

    Kevin

  • Dane JurkovicDane Jurkovic Posts: 12Questions: 6Answers: 0

    Very close. But looking for something that combines

    var table = $('#example').DataTable();
    table.page.jumpToData('Thor Walton', 0);
    
    var info = table.page.info();    
    $('#xCPN').val(info.page);
    

    like this.....

    $('#xCPN').val(table.page.info(table.page.jumpToData('Thor Walton', 0)).page);

  • kthorngrenkthorngren Posts: 20,145Questions: 26Answers: 4,736

    Looking at the code for jumpToData() it has tis comment:

    • @returns {Api} DataTables API instance

    So you can chain the page.info() after jumpToData() like this:
    $('#xCPN').val(table.page.jumpToData('Thor Walton', 0).page.info().page);

    Example:
    https://jsfiddle.net/p9v6ey13/

    Kevin

This discussion has been closed.