Xpages multy upload删除附件

时间:2014-10-21 09:51:03

标签: javascript xpages

我已下载以下opennsf。如果您选择了错误,我想为每个文档添加上传删除选项。我设法在脚本中添加了一个按钮,但我不知道如何将其链接到附件。

以下是编辑过的代码:

var files = document.getElementById('ynFileUploadMulti').files;
        var html = '';
        if (files && files.length > 0) {        
        if(dojo.byId("ynFileUploadInfo").innerHTML == "" )  {
            html = '<table id="ynFileUpload" class="xspDataTableFileDownload" style="width:100%;margin-bottom:1em">';
            html += '<thead style="color:#545454;"><tr><th style="font-weight:bold;width:46px">Size</th><th style="font-weight:bold">Files to Upload</th><th style="font-weight:bold">Delete</th></tr></thead><tbody  style="color:#a0a0a0">';
            }
        else{
            html += dojo.byId("ynFileUploadInfo").innerHTML;
            html = html.replace("</tbody></table>", "");
        }
            for (var i = 0; i < files.length; i++) {
                var file = files[i];
                var fileSize = 0;
                if (file.size > 1024 * 1024)
                 fileSize = (Math.round(file.size / (1024 * 1024))).toString() + ' MB';
                else
                 fileSize = (Math.round(file.size / 1024)).toString() + ' KB';
                html += '<tr><td>'+fileSize+'</td><td>'+file.name+'</td><td ><button onclick="myFunction()">x</button></td></tr>'
            }
            html += '</tbody></table>';
        }
        dojo.byId("ynFileUploadInfo").innerHTML = html;
    } catch (e) {
        console.log("ynUpload_onchange: "+e);
    }

此代码位于ynUploader_onchange()函数中。但我想我也需要触摸其他功能(ynUploader_worker(.....)功能)??我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:0)

您可以使用属性&#34;允许删除&#34;在文件下载控件中,您可以使用以下代码在xpage / cc上放置一个按钮以获取上传文件的句柄

  var attList = document1.getAttachmentList("AttachmentRT");
    for(var i=0; i<attList.size(); i++) 
    {
        var att:String = attList[i];
        // Here you can process every uploaded file
    }

AttachmentRT是绑定到文件下载

的notesrichtext字段的名称