Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Total number of rows

Questions related to using nuBuilder Forte.
Post Reply
marc
Posts: 92
Joined: Mon May 14, 2018 3:26 pm

Total number of rows

Unread post by marc »

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

Unread post by kev1n »

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()
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Total number of rows

Unread post by admin »

People,

I have added browse_filtered_rows to nuFORM.getCurrent() in the latest release.

Steven
marc
Posts: 92
Joined: Mon May 14, 2018 3:26 pm

Re: Total number of rows

Unread post by marc »

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?
kev1n
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

Unread post by kev1n »

This function will show the "rows" of totals "rows" information in the footer of each Browse when added to the header (under setup)
footer_page_info.PNG

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

Unread post by kev1n »

Updated function:
page_info.PNG

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();
}
Edit: The latest update can be found here: https://github.com/smalos/nuBuilder4-Co ... ation_info
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.
marc
Posts: 92
Joined: Mon May 14, 2018 3:26 pm

Re: Total number of rows

Unread post by marc »

That works perfectly. Thank you!!
Post Reply