Jump to content

tablelist.tpl paginating... how to do?


Walther

Recommended Posts

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>

 

Link to comment
Share on other sites

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...

 

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated