'How to implement pagination in salesforce html component file? For HTML table data

I have retrieved data from json and data is also getting displayed in the html table so, I just want to implement pagination functionality for those data. How can I do or add the functionality in the below given JavaScript functionality..

<table id="myTable">
                    <thead>
                        <tr style="border-bottom:none;">
                            <th>
                                <p>Reg. No.</p>
                            </th>
                            <th>
                                <p>Chassis ID</p>
                            </th>
                            <th>
                                <p>Date
                                    <span></span> Time</p>
                            </th>
                            <th>
                                <p>Driver Name</p>
                            </th>
                            <th>
                                <p>Fuel Level (%)</p>
                            </th>
                            <th>
                                <p>Adblue Level (%)</p>
                            </th>
                            <th>
                                <p>Speed (km/h)</p>
                            </th>
                            <th>
                                <p>Odometer (km)</p>
                            </th>
                            <th>
                                <p>Engine Hours (h)</p>
                            </th>
                            <th>
                                <p style="width:55px;">Vehicle status </p>
                            </th>
                            <th>
                                <p>Location</p>
                            </th>
                        </tr>
                    </thead>

                    <tbody id="tbody">

                    </tbody>
                </table>

Javascript:

<script>

    window.onload = function () {

        Visualforce.remoting.Manager.invokeAction(
            '{!$RemoteAction.udcs_fleetstatusoverviewcontroller.fleetStatusData}',
            function (result, event) {
                result = result.replace(/&(lt|gt|quot);/g, function (m, p) { return (p == "lt") ? "<" : (p == "gt") ? ">" : "'"; });
                result = JSON.parse(result.replaceAll("'", '"'));
                let temp = '';

                for (a of Object.keys(result)) {
                    temp += '<tr>';
                    for (b of ["Reg. No.", "Chassis ID", "Date Time", "Driver Name", "Fuel Level (%)", "Adblue Level (%)", "Speed (km/h)", "Odometer (km)", "Engine Hours (h)", "Vehicle status", "Location"]) {
                        let tempstyle ="border-right: 0.5px solid #A6A6A6";
                        tempstyle=(b=='Reg. No.')?tempstyle:""
                        temp += `
                                            <td data-value="${result[a][b]}" style="${tempstyle}">
                                                ${result[a][b]}
                                            </td>
                                            `
                    }
                    temp += '</tr>';

                }
                document.getElementById('tbody').innerHTML = temp;
            },
            {
                escape: true
            }
        );
    }
    function myFunction() {
        let filter = document.getElementById("myInput").value.toUpperCase().trim();
        let tr = document.getElementById("myTable").getElementsByTagName("tr");
        let search_tds = [0,1,3,8];
        for (let i = 1; i < tr.length; i++) {
            let tds = tr[i].getElementsByTagName("td");
            let tempData =[ ];
            for(let a of search_tds){
                tempData.push(tds[a].dataset.value.toUpperCase())
            }
            tr[i].style.display=(tempData.indexOf(filter) > -1 || filter==="")?"":"none";
        }
    }

Here is the code. Hope I can get some help with anyone as soon as possible and Thanks in advance for helping out this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source