I'm looking to implement a paging feature for my query results where I display the first 51 records and store the rest in an array for later retrieval. While I can successfully show the initial 51 results on the page, I'm struggling to figure out how to split the remaining records into arrays of 51.
Here's what my code looks like:
var arrayHTML = [];
for(var key in data){
if(data.hasOwnProperty(key)) {
if (totalX >= 51) {
//Start putting the results into an array. 51 results per array
}else if (x > 1) {
x = 0;
_userName = data[key].fname + ' ' + data[key].lname;
populateCards(_userName,
data[key].email,
data[key].img,
data[key].school,
data[key].userID,
true,
data[key].encoded);
} else {
_userName = data[key].fname + ' ' + data[key].lname;
populateCards(_userName,
data[key].email,
data[key].img,
data[key].school,
data[key].userID,
false,
data[key].encoded);
x++;
}
totalRowCnt = data[key].totalRows;
_tmpMath = Math.round(totalRowCnt / totalNum);
total++;
totalX++;
console.log('totalX: ' + totalX)
}
}
Once it reaches the 51 record mark, it enters the if (totalX >= 51) { block where I'm trying to devise a method to split the remaining records into arrays with 51 entries each.
The current code loops until every 3rd record, then inserts a <br/> tag to create rows of 3 records each. This pattern continues until reaching the 51st record, resulting in 17 rows of 3 records each. The true flag adds a <br/> tag at the end of each row, while false skips adding it temporarily.
I would greatly appreciate any assistance!