how to initiate the loading of a table not from the first but from another page?

how to initiate the loading of a table not from the first but from another page?

izumovizumov Posts: 178Questions: 14Answers: 0
edited February 2020 in Free community support

I need to load not the first but the other page when the table is initiated. Is it possible to do this?
my test case is http://montaj.vianor-konakovo.ru/goods_new111.html
in line 1158 of the goods_nev.js file I give the command to go to page 6:

table.page (5);

but the table does not load this page what could be the problem? And is it possible to initiate a table right away, for example from page 6?

Replies

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    If you are using serverSide processing then you may be interested in the deferLoading option as shown in the example.

    The page() docs state this:

    Please be aware that this method sets the page to be shown - it does not actually perform the re-display of the table. In order to have the newly set page shown use the draw() method

    See examples in the page() docs.

    Kevin

  • izumovizumov Posts: 178Questions: 14Answers: 0

    in the developer tool, I saw that on command

     table.page(5).draw(false);
    

    forms a request ajax with the parameter start=0
    I think this is the problem. And why this happens I can not understand.

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921
    edited February 2020

    forms a request ajax with the parameter start=0

    Sounds like you are using server side processing. Did you use the deferLoading option? This example works with deferLoading.
    http://live.datatables.net/fujiqalo/1/edit

    table.page(5).draw(false);

    Where do you have this? If you are using it directly after initialing Datatables, like this:

    $(document).ready(function() {
        var table = $('#example').DataTable( {
            "processing": true,
            "serverSide": true,
            "ajax": "/ssp/objects.php",
        } );
      
      table.page(5).draw(false);
    } );
    

    Then it is going to execute before the Ajax response (and Datatables initialization). This code won't load page 5.

    **EDIT:*** You can see this not work if you comment out the deferLoading option in my example.

    Kevin

  • izumovizumov Posts: 178Questions: 14Answers: 0

    I have two variables known before the initiation of the table — the page number and page size. I need to optimally display the page with the specified size and number in the shortest time. How to do it?

  • izumovizumov Posts: 178Questions: 14Answers: 0

    variables change from time to time. And when I say the best way, I mean that it is advisable without the overhead of loading and displaying the first page

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    Maybe I'm not understanding the real question as it seems we keep going over the same answers.

    without the overhead of loading and displaying the first page

    Use deferLoading to keep Datatables from requesting the first page on initialization. This is used with serverSide processing. Are you using server side processing?

    the page number and page size. I need to optimally display the page with the specified size and number

    Use page.len() to set the page followed by page() to load the page.

    I updated the example to show setting the page length:
    http://live.datatables.net/fujiqalo/2/edit

    If this doesn't help then please update my example with what you are trying to do.

    Kevin

  • izumovizumov Posts: 178Questions: 14Answers: 0

    can this be done immediately after the initiation of the table?

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    can this be done immediately after the initiation of the table?

    That is what my example is showing.

    Kevin

  • izumovizumov Posts: 178Questions: 14Answers: 0

    I am immensely grateful to you for constructive valuable advice. Following them, I made adjustments to the code and the very first attempt was successful.

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    Fantastic, glad you got it!

    Kevin

  • izumovizumov Posts: 178Questions: 14Answers: 0

    Fiction I'm immensely happy myself much closer to the completion of the project. You are a wizard of code. Could you expertly estimate the loading time of my page?

  • izumovizumov Posts: 178Questions: 14Answers: 0

    Could you, as an expert, evaluate the loading speed of my page http://montaj.vianor-konakovo.ru/goods_new111.html?

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    See if this tutorial helps you to profile your web pages.

    Kevin

  • izumovizumov Posts: 178Questions: 14Answers: 0

    sorry I was interested in your expert opinion.the fact is that in my opinion the page loads quite quickly. The customer wants to quickly answer the question how much faster I did not receive an answer. Yes, and I could hardly get it because this is an area of subjective sensations

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    Profiling a page is not my area of expertise. Allan could probably help but you will likely need to pay for that service.

    Kevin

This discussion has been closed.