ajax.reload is lazy-loading and resizing

ajax.reload is lazy-loading and resizing

dvoldvol Posts: 2Questions: 1Answers: 0

Hello together,

it's my first time working with DataTables but I really enjoy the functionality of the framework.
While developing i happened to get two behaviours i didn't expect:

  1. Resizing
    I have a server-side-processed dataTable on my page which is initialized when the document is ready (jQuery).
    Sometimes the width of the table-header-row isn't calculated probably so the visual result looks kinda buggy.
    The table body is sized perfectly after loading the data but the header-row is only at minimum width and not as wide as the body.

  2. ajax.reload
    The API-Method ajax.reload seems to be lazy-loading. It only works for me if i change a property of the API-object via the search method (or any other method) before i call ajax.reload.
    Is there anyway to force the ajax reload?

Greetings dvol

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,667Questions: 26Answers: 4,836
    edited January 2018 Answer ✓
    1. General recommendation is to add width="100%" to the table. If the table is not visible when initialized then use columns().adjust() when it becomes visible.

    2. Are you using ajax within the Datatables init code? If the ajax config is outside of Datatables then ajax.url().load() might work. Although if you are using additional ajax parameters outside of DT like POST they won't be used.

    If this doesn't help then please post a link to your page or a test case so we can see what you are doing.

    Kevin

  • dvoldvol Posts: 2Questions: 1Answers: 0
    1. I already am using columns().adjust() (which is fixing the problem), but i was wondering why i need it, since the table is visible from the beginning (only the data is loaded with ajax). Anyway i will try to make a test-site in my freetime where you can see the problem.
    2. I found the problem: I am using the server-side processing script from your examples (https://datatables.net/examples/data_sources/server_side.html). This script is checking if anything changed from the last url (which wasnt the case in my scenario) before making the ajax request.

    Thx for the fast response and have a nice day!

This discussion has been closed.