1 function UploadFileModalDialog(inputid) {
 2         var url = ProcessData.SiteURl + "/_layouts/Attachfile.aspx?ListId={" + ProcessData.ListID + "}&ItemId=" + ProcessData.ListItemID;
 3         //var url = "siteurl/_layouts/Upload.aspx?List=" + listId + "&RootFolder=" + folderPath; 
 4         var options = {
 5             url: url,
 6             width:600,
 7             height:300,
 8             dialogReturnValueCallback: function (result, fileAdded) { 
 9                 if (result == SP.UI.DialogResult.OK) { 
10                     GetFileObjeData()
11                    
12                 }
13             }
14         };
15         SP.UI.ModalDialog.showModalDialog(options);
16     }
function GetFileObjeData() { 
    var clientContext = new SP.ClientContext.get_current();
    var web = clientContext.get_web();
    var attachmentFolder = web.getFolderByServerRelativeUrl("Lists/" + ListTitle + "/Attachments/" + ListItemID);
    attachmentFiles = attachmentFolder.get_files();
    clientContext.load(attachmentFiles);
    clientContext.executeQueryAsync(
        Function.createDelegate(this, onQueryFilesSucceeded),
        Function.createDelegate(this, onQueryFilesFailed)
    );
    function onQueryFilesSucceeded() {
        var i = 0;
        for (var file in attachmentFiles) {
            alert(attachmentFiles.itemAt(i).get_serverRelativeUrl());
            i++;
        } 
    }
    function onQueryFilesFailed(sender, args) {
        alert("Initialize the data failed!");
    }
}

  

posted on 2014-09-25 13:34  胖子哥哥  阅读(218)  评论(0)    收藏  举报