tablesorter paginate not working
This HTML page I am rendering goes on the bottom of a pricelist page. When I try to call tablesorter on the table, i get the following error.. which is very strange. Can't seem to figure out why its throwing this error.
Uncaught TypeError: ts.appendCache is not a function
at init (jquery.tablesorter.pager.js:1139)
at HTMLTableElement.<anonymous> (jquery.tablesorter.pager.js:1181)
at Function.each (jquery-latest.js:45)
at init.each (jquery-latest.js:38)
at init.$this.construct [as tablesorterPager] (jquery.tablesorter.pager.js:1178)
at HTMLDocument.<anonymous> (loadDWPriceListItemGrid.html?&filter=pt_designwinpricelistid='51f0d425-5888-e711-a061-000c293ddc16'&id=51f0d425-5888-e711-a061-000c293ddc16&orgname=CRMDEV:54)
at Function.ready (jquery-latest.js:41)
at HTMLDocument.L (jquery-latest.js:48)
My page html:
<body style="justify-content: justify">
<div id="tableContainer">
<div style="justify-content: center; float:left">
<table id="partsTable" class="tablesorter">
<thead id="tableHead"></thead>
<tbody id="tableBody"></tbody>
</table>
<div id="pager" class="pager">
<form>
<img src="../_imgs/first.png" class="first" />
<img src="../_imgs/prev.png" class="prev" />
<input type="text" class="pagedisplay" />
<img src="../_imgs/next.png" class="next" />
<img src="../_imgs/last.png" class="last" />
<select class="pagesize">
<option value="">>LIMIT</option>
<option value="2">2 per page</option>
<option value="5">5 per page</option>
<option value="10">10 per page</option>
</select>
</form>
</div>
</div>
</div>
and my javascript:
$(document).ready(function() {
$("#partsTable").tablesorter({
theme: 'blue',
widthFixed: true,
widgets: ['zebra']
}).tablesorterPager({
container: $("#pager")
});
var pricelistId = getParameterByName("id");
var orgname = getParameterByName("orgname");
getPriceListItems(pricelistId, orgname);
var table = document.getElementById("partsTable");
table.border = "5";
table.style = "width: 100%; table-layout: flex;";
var header = document.getElementById("tableHead");
var columnCount = 8;
var row = header.insertRow(-1);
var headerCell0 = document.createElement("TH");
headerCell0.innerHTML = "Price List Name";
row.appendChild(headerCell0);
var headerCell = document.createElement("TH");
headerCell.innerHTML = "Part Number";
row.appendChild(headerCell);
var headerCell1 = document.createElement("TH");
headerCell1.innerHTML = "SPA";
row.appendChild(headerCell1);
var headerCell8 = document.createElement("TH");
headerCell8.innerHTML = "Quantity";
row.appendChild(headerCell8);
var headerCell9 = document.createElement("TH");
headerCell9.innerHTML = "Quantity Type";
row.appendChild(headerCell9);
var headerCell2 = document.createElement("TH");
headerCell2.innerHTML = "Customer Part Number";
row.appendChild(headerCell2);
var headerCell3 = document.createElement("TH");
headerCell3.innerHTML = "Design Registration";
row.appendChild(headerCell3);
var headerCell4 = document.createElement("TH");
headerCell4.innerHTML = "Lead Time";
row.appendChild(headerCell4);
var headerCell5 = document.createElement("TH");
headerCell5.innerHTML = "Quoted Cost";
row.appendChild(headerCell5);
var headerCell6 = document.createElement("TH");
headerCell6.innerHTML = "Quoted User Price";
row.appendChild(headerCell6);
var headerCell7 = document.createElement("TH");
headerCell7.innerHTML = "Status";
row.appendChild(headerCell7);
row.style = "background-color: lightgrey"
function getPriceListItems(id, orgname) {
trakPlatformClient.RequestHandler.Execute({
request: {
orgName: orgname,
messageName: "get_dwpricelistitem",
parameters: [{
Key: "pt_designwinpricelistid",
Value: id
}]
},
context: this,
responseHandler: getItemSuccess,
handlerArgument: null,
errorHandler: getItemError
});
}
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
function getItemSuccess(result, handlerArgument) {
var parts = new Array();
for (var i = 0; i < result.Table.Rows.length; i++) {
parts.push(result.Table.Rows[i]);
}
console.log(parts);
var tableBody = document.getElementById("tableBody");
for (var i = 0; i < parts.length; i++) {
var pt_designwinpricelistidname = parts[i].pt_designwinpricelistidname;
var pt_designwinpricelistitemid = parts[i].pt_designwinpricelistitemid;
var row = tableBody.insertRow(-1);
var hiddenCell = row.insertCell(-1);
hiddenCell.id = "pricelistID" + i;
hiddenCell.value = pt_designwinpricelistitemid;
hiddenCell.innerHTML = pt_designwinpricelistidname;
hiddenCell.style.visibility = "visible";
var pt_partidname = parts[i].pt_partidname;
var am_spaname = parts[i].am_spaname;
var am_quantitytype = parts[i].am_quantitytype;
var quantity = parts[i].quantity;
var am_customerpartnumber = parts[i].am_customerpartnumber;
var pt_designregistrationpartidname = parts[i].pt_designregistrationpartidname;
var am_leadtime = parts[i].am_leadtime;
var am_quotedcost = parts[i].am_quotedcost.toPrecision(5);
var am_quoateduserprice;
if (parts[i].am_quoteduserprice != null) {
am_quoateduserprice = parts[i].am_quoteduserprice.toPrecision(5);
} else {
var num = 0
am_quoateduserprice = num.toPrecision(5);
}
var statuscode = parts[i].statuscode;
var statuscodename;
if (statuscode == 1) {
statuscodename = "Active";
} else {
statuscodename = "Inactive";
}
var quantitytypename;
if (am_quantitytype == 1) {
quantitytypename = "Annual"
} else if (am_quantitytype == 2) {
quantitytypename = "Quarterly"
} else {
quantitytypename = "One Shot"
}
var attributes = new Array();
attributes.push(pt_partidname);
attributes.push(am_spaname);
attributes.push(quantity);
attributes.push(quantitytypename);
attributes.push(am_customerpartnumber);
attributes.push(pt_designregistrationpartidname);
attributes.push(am_leadtime);
attributes.push(am_quotedcost);
attributes.push(am_quoateduserprice);
attributes.push(statuscodename);
for (var j = 0; j < attributes.length; j++) {
var cell = row.insertCell(-1);
cell.innerHTML = attributes[j];
if (j == 0) {
cell.style = "text-decoration: underline";
}
}
}
tableBody.appendChild(table);
}
function getItemError(e, s, t) {
console.log(e);
}
});
Table loads perfectly fine if I comment out the first 7 lines in document.ready, but without pagination/sorting, but when i use $("table") or $("#partsTable") it throws that error.. any help is appreciated!