Make ajax call only on pagination change

Make ajax call only on pagination change

TronikTronik Posts: 121Questions: 28Answers: 1

Hi,

I use Editor library to load data into the table with the service-side option.
I also load an image from another server of mine,

{
"data": "id",
  render: function ( data, type, row ) {
                
    if(row.type.type.includes("image")) 
    return "<a target='_blank' href='https://api.server/assets/"+data+"'><img style='margin:0;' src='https://api.server/assets/"+data+"?key=thumbnail'></a>";
                    
else
    return "";
       }
},

Naturally Datatables will load all rows (15000+) along with all the image thumbnails, which seems uneccesary heavy for my api server, the image loading I mean.
I can see in chrome inspection that it loads every single image

Using Scroller plugin works in that regard that it will only make ajax call when the break point is reached, but Im not really happy with how the rows load visually (jumps in table when the rows and images are loaded).

I thought that regular pagination only made ajax call when page changed but i found out that it loads all data from server.

Was trying the https://gyrocode.com/articles/jquery-datatables-load-more-button/ which i find really nice in terms of UI

Scroller with a load more button would be the best but given the plugin name I realize that is not an option :)

Answers

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794

    but Im not really happy with how the rows load visually (jumps in table when the rows and images are loaded).

    What do you mean by "jumps in table"?

    I thought that regular pagination only made ajax call when page changed but i found out that it loads all data from server.

    Server side processing is a client/server model. When serverSide is enabled Datatbles will send a request for the page to the server. You will need a server script that supports the server side processing protocol to support server based paging. It sounds like you might not be using a server script that supports server side processing. What are you using?

    Can you post a link to a test case showing these issues?
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    I'm not familiar with the Gyrocode Load More plugin. You can ask the developer questions about the plugin.

    Kevin

Sign In or Register to comment.