0

XPages では、チェック ボックスで選択された値に基づいてビューから値を抽出しようとしています。

を含む「viewpanel2」というビューがありLoggerID、それぞれLoggerIDが数値で構成されています。

LoggerID横のチェックボックスが選択され、ボタンがクリックされたときに、javascript を使用してビューから値を抽出するボタンがあります。私が抱えている問題は、LoggerID選択されたものだけでなく、ビュー内のすべての のすべての値を出力し続けることです。

ボタンのコードは次のとおりです。

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条件が機能していないと思います。誰でも解決策を提案できますか?

4

3 に答える 3

7

比較ではなく、割り当てを行っています。これを行う:

if (moo === vwEntry) {

または、それらが同じタイプの場合は、'===' を使用する必要があります。

于 2013-06-06T15:45:16.607 に答える
2

あなたが間違っている部分はそこにあります:

if (moo = vwEntry) {

主な理由は=、JavaScript のシングル サインは変数に値を代入することを意味するためです。

==2 つの値を比較するか、同一===である必要がある 2 つの値を比較するために使用する必要があります。



Javascript表記

=

課題です。


==

比較です


===

値を同一にする比較です (同じvaluetype )。

于 2013-06-06T15:56:13.210 に答える