Walther Posted Friday at 08:55 PM Share Posted Friday at 08:55 PM I'm trying to create a page to display a report with several thousand records using tablelist.tpl. The problem is that I can't get pagination to work: it always shows all the (2000+) records on a single screen, whereas I would like them to be displayed in groups (10, 25, or 50), as is done, for example, in clientareadomains.tpl. However, I haven't been able to find any documentation on tablelist.tpl anywhere, so I have no idea how to implement this... Below is my TPL code: {include file="$template/includes/tablelist.tpl" tableName="DomainsResellerLogs" noSortColumns="4,5,6" filterColumn="0"} <script type="text/javascript"> jQuery(document).ready(function() { var table = getTableInstance('DomainsResellerLogs'); table.on('draw.dt', function() { //further customizations as needed }); }); </script> <div class="table-container"> <table id="tableDomainsResellerLogs" class="table table-list"> <thead> <tr> <th>Date</th> <th>Order ID</th> <th>Rel ID</th> <th>Request</th> <th>Response</th> <th>Result</th> <th>IP</th> </tr> </thead> <tbody> {foreach from=$logs item=log} <tr> <td><pre>{$log->date|wordwrap:10:"<br>":true}</pre></td> <td>{$log->order_id}</td> <td>{$log->relid}</td> <td><pre>{$log->request|wordwrap:40:"<br>":true}</pre></td> <td><pre>{$log->response|wordwrap:40:"<br>":true}</pre></td> <td>{$log->result}</td> <td><pre>{$log->ip}</pre></td> </tr> {/foreach} </tbody> </table> </div> 0 Quote Link to comment Share on other sites More sharing options...
DristiTechnologies Posted Monday at 01:59 AM Share Posted Monday at 01:59 AM Try this <script> jQuery(document).ready(function () { const table = getTableInstance('DomainsResellerLogs'); table.DataTable({ pageLength: 25, // Default rows per page lengthMenu: [10, 25, 50, 100], order: [[0, 'desc']], // Optional default sorting }); }); </script> 0 Quote Link to comment Share on other sites More sharing options...
Walther Posted Monday at 03:58 PM Author Share Posted Monday at 03:58 PM 13 hours ago, DristiTechnologies said: Try this <script> jQuery(document).ready(function () { const table = getTableInstance('DomainsResellerLogs'); table.DataTable({ pageLength: 25, // Default rows per page lengthMenu: [10, 25, 50, 100], order: [[0, 'desc']], // Optional default sorting }); }); </script> Nope, it doesn't work... 😟 I guess something must be set in PHP code too, but I can't find any example or documentation about... 0 Quote Link to comment Share on other sites More sharing options...
Mytihost Posted Monday at 06:25 PM Share Posted Monday at 06:25 PM This is an AI generated response to your query <script type="text/javascript"> jQuery(document).ready(function() { var table = jQuery('#tableDomainsResellerLogs').DataTable({ pageLength: 25, // default rows per page lengthMenu: [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ], ordering: true, searching: true, paging: true }); table.on('draw', function() { // Optional: trigger any redraw logic }); }); </script> 0 Quote Link to comment Share on other sites More sharing options...
bear Posted Monday at 09:58 PM Share Posted Monday at 09:58 PM 3 hours ago, Mytihost said: This is an AI generated response to your query You should write your own. AI is not to be trusted. 1 Quote Link to comment Share on other sites More sharing options...
Mytihost Posted Monday at 10:35 PM Share Posted Monday at 10:35 PM 33 minutes ago, bear said: You should write your own. AI is not to be trusted. Maybe you can solve there issue for them instead of commenting on what people should or shouldn't be doing. The same AI has saved me hundreds of pounds in whmcs development costs and it's also helped out other people on these forums in the past with no complaints. 0 Quote Link to comment Share on other sites More sharing options...
bear Posted Tuesday at 01:36 AM Share Posted Tuesday at 01:36 AM "Maybe you can solve there issue for them". Why? You didn't. 😉 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted Tuesday at 09:42 PM Share Posted Tuesday at 09:42 PM @bear is right in this case. AI is generally only a help if you already know what you're doing. @MytihostYou can't solve the issue using Javascript. Javascript is a client side language, so you can only use it to manipulate the data you already have received from the client. If you only want to get a set amount of records for each page, you could use the limit() and offset() methods on your collection. Unfortunately, WHMCS doesn't support the paginate() method provided by Laravel. If you're retrieving thousands of records from the database, it's going to be slower than retrieving 50. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.