有人知道如何从数组中删除选定的项目吗?
var view:NotesView = getComponent("viewPanel2");
var UtbildningarArray = new Array();
viewScope.col = view.getSelectedIds();
if (viewScope.col.length > 0){
for (i=0; i<viewScope.col.length; i++){
var docid = viewScope.col[i];
if (docid != null) {
var doc = database.getDocumentByID(docid);
UtbildningarArray.push(doc.getItemValueString("Namn"))
}
}
}
document1.removeItemValue("Utbildningar",UtbildningarArray);
document1.save();
我已经尝试过,removeEntry 和 splice 但没有成功。
谢谢, 乔纳斯
编辑:
你是对的,已在代码中添加了以下内容:
var view:NotesView = getComponent("viewPanel2");
var UtbildningarArray = new Array();
var UtbildningarArray = new Array();
var FieldUtbArray = new Array(getComponent('inputHidden1').getValue());
viewScope.col = view.getSelectedIds();
if (viewScope.col.length > 0){
for (i=0; i<viewScope.col.length; i++){
var docid = viewScope.col[i];
if (docid != null) {
var doc = database.getDocumentByID(docid);
UtbildningarArray.push(doc.getItemValueString("Namn"))
}
}
}
document1.replaceItemValue("Utbildningar",FieldUtbArray.slice(UtbildningarArray));
document1.save();
我正在保存用户在隐藏输入中选择的内容,当用户单击“删除程序”按钮时,我会在 View 中显示所选类(class)。然后,用户应该能够单击复选框并删除所选类(class)。现在,当我保存时,什么也没有发生。
最佳答案
我认为你需要更多地展示你想要删除的内容。
下面您必须编写代码片段,从 js 数组中删除条目。
http://openntf.org/XSnippets.nsf/snippet.xsp?id=remove-an-entry-from-an-array-of-strings
http://dontpanic82.blogspot.se/2010/10/code-snippet-arraysplice-according-to.html
关于javascript - Xpages - 从数组中删除选定的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22609550/