質問

I have a view panel in xpages and a computed field to show the row-count. I have 2 problems:

1st: how can i count only the rows of the current page of the pager?it seems that viewPanel.getRowCount() gets all rows from the beginning until the current page, so if i have 30 entries per page and i am in page 2, it shows 60 instead of 30.

2nd: even if i achieve the above, the pager only refreshes the view and i can't refresh the computed field or another panel. Can i put the computed field inside the view panel or make it somehow to be refreshed in each page change? i would prefer not to do it with full page refresh if possible...

役に立ちましたか?

解決

Given the computed field refresh issue, even if you managed to get a count of rows (eg on a page-scope SSJS variable), it woudln't update the computed field.

It might be easier to to count to rows in the HTML table using clientside javascript ?

something like ..

page onload event :

get the HTML table
get the table rows property (array of rows in the table)

number or rows = that value (1st row = TH (header) row if there is one = row 0)

use javsscript to plug that value into a known DIV

他のヒント

You could also hijack the partial refresh issued from the pager and check for the ID that has been refreshed. If the ID match your view panel's ID, you could do another partial update in order to update another panel.

Example code for hijacking the partial refresh:

var sysHijackPartialRefresh = function(){
    XSP._inheritedPartialRefresh = XSP._partialRefresh;
    XSP._partialRefresh = function( method, form, refreshId,options) {


    if (options){
        if (!options.onComplete) { 
            options.onStart = function(){ 

            };
            options.onComplete = function(){
                if (refreshId == "<client id of view panel>") {
                // issue another partial refresh
                XSP.partialRefreshGet(<client id of the other panel>);
                }
            }; 
        } 
    }
    this._inheritedPartialRefresh(method, form, refreshId, options); }
}

XSP.addOnLoad(sysHijackPartialRefresh);

See http://xpageswiki.com/web/youatnotes/wiki-xpages.nsf/dx/Work_with_events_and_partial_or_full_refresh for more information about partial updates.

The pager should have a "refreshID" property in which you can put the client ID (!) of the panel you want to refresh. Use getClientId() to compute the client ID of the panel.

For the row count: use the XPages debug toolbar (from openNTF) to check for a property of the view panel or the pager which gives you the current page number. If you got that, you can simply compute by using viewPanel.getRowCount() - (page number * number of rows per page).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top