在 XPages 中,我试图根据通过复选框选择的视图从视图中提取一个值。
我有一个名为“viewpanel2”的视图,其中包含LoggerID
s,每个LoggerID
都由一个数值组成。
I have a button which extracts values from the view using javascript when a check box next to the LoggerID
is selected and the button is clicked. 我遇到的问题是它不断打印LoggerID
视图中所有 s 的所有值,而不仅仅是已选择的一个。
这是按钮的代码:
var viewPanel = getComponent("viewPanel2"); //in the view panel select the check box
var docIDArray = viewPanel.getSelectedIds(); //get that selected ID
for (i = 0; i < docIDArray.length; i++) {
var docId = docIDArray[0];
var doc = database.getDocumentByID(docId);
var moo = doc.getItemValue("LoggerID"); //selected ID is defined
var vw = database.getView('BrowserStats'); //Get the Notesview
var vwEntries = vw.getAllEntries(); //Get handle of all entries
var vwCount = vwEntries.getCount(); //Get the Count to use as uBound
var vwEntry = vwEntries.getFirstEntry(); //Get first value
//Get the first entry and get the column value of the first entry
var plot_LoggerID = vwEntry.getColumnValues().elementAt(2);
for (var x = 1; x < vwCount; x++) {
//Looping through all the entries and collect the column values
vwEntry = vwEntries.getNextEntry(vwEntry);
plot_LoggerID = plot_LoggerID + "," + vwEntry.getColumnValues().elementAt(2);
}
//comparing the entries to the selected ID and if found extracting the values for LoggerID
}
if (moo = vwEntry) {
getComponent("extracted_LoggerID").setValue("["+plot_LoggerID+"]");
} else {
print = ("no data available");
}
我相信我拥有的 if 条件不起作用。任何人都可以提出解决方案吗?