0

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.

Ryan Buening
  • 1,559
  • 2
  • 22
  • 60

1 Answers1

3

I think I have it figured out.

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);
Ryan Buening
  • 1,559
  • 2
  • 22
  • 60
  • interesting, I just reported this as a bug before I saw your solution here http://www-10.lotus.com/ldd/ndsebetaforum.nsf/topicThread.xsp?action=openDocument&documentId=173B8E2826C07E6285257B1A0058EBEA – Thomas Adrian Feb 22 '13 at 19:10
  • I found an issue with this method. It seems as though getRowCount() doesn't return the correct number of rows until the view is filtered: www-01.ibm.com/support/docview.wss?uid=swg1LO58916. It appears that it only caches the first two "pages" of documents. Does anyone know a way to work around this? – Ryan Buening Feb 22 '13 at 21:16
  • Try ViewPanelComponent.getEntryCount() when the view isn't filtered. In your case, temprows.getEntryCount() – Tommy Valand Feb 23 '13 at 08:36
  • Doesn't let me use getEntryCount(): Unknown member 'getEntryCount' in Java class 'com.ibm.xsp.component.xp.XspViewPanel' – Ryan Buening Feb 24 '13 at 21:46