Get entries count for a multiple category view (two categories) using a key (Xpages)

心不动则不痛 提交于 2019-12-12 15:19:50

问题


I am trying to retrieve the entries count for a multiple category view (two categories) using a key.

var db:NotesDatabase = session.getDatabase(sessionScope.serverPath,sessionScope.dbName);
var luview = db.getView(sessionScope.viewName);
var vec:NotesViewEntryCollection = null;
if (key != null) {
vec = luview.getAllEntriesByKey(key);
}
count = vec.getCount().toFixed()

The count being returned is incorrect. I have over 500 documents in the view. It seems to be returning just the document count (20) of the first sub-category.

I've found mention of this as a bug in the forums. I'm running this on a 9.0 server. Any pointers would be much appreciated.

What I would like is the total count - categories (25) + documents (500), that I can use in the repeat control limit.

Thanks,

Dan


回答1:


I was able to resolve this by using the NotesViewNavigator.

var nav:NotesViewNavigator = v.createViewNavFromCategory(key);
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) { 
count = count + 1;
var tmpentry:NotesViewEntry = nav.getNext(entry);
entry.recycle();
entry = tmpentry;
}



回答2:


Dan - If you can get the entry count into the view column with an @AllChildren... or @AllDecendents or something like that then using the view navigator you should be able to read that value in and not have to actually loop through all the documents.

Another way is to create a different view, could be hidden, and not categorize that second column. Then you're original solution should work I'd think.



来源:https://stackoverflow.com/questions/27028179/get-entries-count-for-a-multiple-category-view-two-categories-using-a-key-xpa

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!