Hi,
Can I get the total number of rows of a browse table? E.g. if there are 20 pages with 20 rows in each page, the total would be 400 rows in total.
I was looking at nuCurrentProperties() but was not able to find that figure.
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Total number of rows
-
- nuBuilder Team
- Posts: 4307
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 448 times
- Contact:
Re: Total number of rows
The funtion nuBrowseRows() calls db_num_rows() to obtain the number of rows of a the Browse SQL query Then, in nuGetFormObject(), this number is assigned to $f->browse_height = $B[1];
https://github.com/steven-copley/nubuil ... m.php#L326
It's probably no big deal for Steven to add a new property like total_rows to nuCurrentProperties()
https://github.com/steven-copley/nubuil ... m.php#L326
It's probably no big deal for Steven to add a new property like total_rows to nuCurrentProperties()
Re: Total number of rows
People,
I have added browse_filtered_rows to nuFORM.getCurrent() in the latest release.
Steven
I have added browse_filtered_rows to nuFORM.getCurrent() in the latest release.
Steven
-
- Posts: 92
- Joined: Mon May 14, 2018 3:26 pm
Re: Total number of rows
Perfect! Now I'm looking for a way to display the rows and total rows in the table footer.
On Page 1, I would see (20/75), on Page 2: (40/75), Page 3: (60/75), Page 4: (75/75). Is that possible?
On Page 1, I would see (20/75), on Page 2: (40/75), Page 3: (60/75), Page 4: (75/75). Is that possible?
-
- nuBuilder Team
- Posts: 4307
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 448 times
- Contact:
Re: Total number of rows
This function will show the "rows" of totals "rows" information in the footer of each Browse when added to the header (under setup)
Code: Select all
function filteredRowsOfTotalRows() {;
rpp = $("div[id^='nucell_']" + "[id$='_1']").length // rows per page
with(nuFORM.getCurrent()) {
cp = page_number; // current page
fr = browse_filtered_rows;
pc = pages // total pages
}
var r = '';
if (pc == cp + 1 || cp + 1 == pc) {
r = fr
} else
if (cp == 0 && pc > 1) {
r = rpp
} else
if (cp > 0 && cp < pc) {
r = (cp + 1) * rpp;
};
return r + ' of ' + fr;
}
function nuOnLoad() {
if (nuFormType() == 'browse') {
$('#nuBrowseFooter').append('<span style="float:left;vertical-align: middle;line-height: 25px;padding-left:5px">' + filteredRowsOfTotalRows() + '</span>');
}
}
You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4307
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 448 times
- Contact:
Re: Total number of rows
Updated function:
Edit: The latest update can be found here: https://github.com/smalos/nuBuilder4-Co ... ation_info
Code: Select all
function getPaginationInfo() {
r = $("div[id^='nucell_']" + "[id$='_1']").length // Number of Rows per page
with(nuFORM.getCurrent()) {
c = page_number; // Current page number
f = browse_filtered_rows; // Number of records in the table after filtering
p = pages; // Total number of pages
}
var e; // Row number of the last record on the current page
var s; // Row number of the first record on the current page
if (c == 0 && f > 0 & p == 1) {
s = 1;
e = f;
} else
if (p == c + 1 || f == 0) {
s = f == 0 ? 0 : c * r + 1;
e = f
} else
if (c == 0 && p > 1) {
s = 1;
e = r;
} else
if (c > 0 && c < p) {
e = (c + 1) * r;
s = e - r + 1;
};
return {
startRow: s,
endRow: e,
filteredRows: f
};
}
function showPaginationInfo() {
if (nuFormType() == 'browse') {
var {
startRow,
endRow,
filteredRows
} = getPaginationInfo();
var p = "Showing " + startRow + " to " + endRow + " of " + filteredRows + " entries";
$('#nuBrowseFooter').append('<span style="float:left;vertical-align: middle;line-height: 25px;padding-left:5px">' + p + '</span>');
}
}
function nuOnLoad() {
showPaginationInfo();
}
You do not have the required permissions to view the files attached to this post.
Last edited by kev1n on Mon Apr 27, 2020 6:43 pm, edited 1 time in total.
-
- Posts: 92
- Joined: Mon May 14, 2018 3:26 pm