Get Column Values of Searched (Filtered) View Resu

2019-08-16 19:57发布

问题:

I am doing a search query on a viewPanel. When the results get displayed in the view, I want to loop through only the returned results and build an array of names for each row. I have the Name field in the first column of my Xpage view. I have tried the following:

var viewControl = getComponent("namesPanel");
var view = viewControl.getDataModel().getDominoViewData().getDataObject();
var entries = view.getAllEntries();
var entry = entries.getFirstEntry();

var namesArray = [];
while(entry)
{
    namesArray.push(entry.getColumnValues().elementAt(0));
    entry = entries.getNextEntry();
}

getComponent("DisplayNames").setValue(namesArray);

The above code returns every name in the backend Notes view regardless of my search query. I realize there is getAllEntriesByKey(), but my Xpages view is filtered by a search, not by column values.

Is there a way I can build an array of column values on only the displayed results in my view after a search? Thanks for any tips.

回答1:

I think I have it figured out. Found some help here: http://www.xsptalk.com/Public/Website/Blog.nsf/dx/04032011122915CCOGNE.htm

var temprows = getComponent("namesPanel");
var modelData = temprows.getDataModel();
var namesArray = [];

for(i=0; i < modelData.getRowCount(); i++)
{
    modelData.setRowIndex(i);
    var xspViewEntry=modelData.getRowData();
    var document=xspViewEntry.getDocument();
    namesArray.push(document.getItemValueString("name"));
}

getComponent("DisplayNames").setValue(namesArray);