本文介绍了单击按钮触发Kendo上传的OnCancel事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过单击取消"按钮来取消上传的文件.
I want to Cancel the file uploading on click of cancel button.
表示我想点击取消按钮
我的代码是
@(Html.Kendo().Upload()
.Name("files")
.Multiple(false)
.Async(a => a
.Save("UploadArtifactFile", "PP", new { TeacherEvalID = ViewBag.TeacherEvalID, ObservationID = ViewBag.ObservationID, Accountid = ViewBag.AccountID })
.AutoUpload(false)
.RemoveField("")
)
.Events(events => events
.Success("onSuccess")
.Select("onSelect")
.Error("onUploadError")
.Upload("onUpload")
.Cancel("onCancel")
.Remove("onRemove")
)
On cancel event is work as expected,
function onCancel(e) {
//Array with information about the uploaded files
var files = e.files;
e.preventDefault();
}
我想对取消按钮"做同样的事情,单击取消按钮"时,我写的代码是
I want to do the same thing for Cancel Button and on click of cancel button i have write code as,
function setNewArtifact() {
var upload = $("#files").data("kendoUpload");
//detach events and prepare for safe removal
//upload.destroy();
$(".k-upload-files.k-reset").find("li").remove();
$('#lblArtifactFileName').val("");
$('#lblArtifactFileName').hide();
//hdnArtifactUploadIsAddOrEdit :1 for new artifact (Add)
$('#hdnArtifactUploadIsAddOrEdit').val("1");
$('#txtArtifactDescription').val("");
$('#lblArtifactFileName').hide();
$('#btnModifyArtifact').css("display", "none");
$('.k-upload-selected').css("display", "none");
//on click of cancel hide the uploading and uploaded status
$(".k-dropzone").find("strong").css("display","none");
$(".k-upload-status.k-upload-status-total").find("span").css("display","none");
$.extend(upload.options.localization, {
headerStatusUploading: "",
headerStatusUploaded: ""
});
}
有什么办法吗?
请帮助...
推荐答案
您可以触发上传取消事件:
You can trigger upload cancel event:
$(document).ready(function() {
$("#files").kendoUpload({
async: {
saveUrl: "save",
removeUrl: "remove",
autoUpload: true
},
cancel: function(e) {
alert("cancel");
}
});
$("#button").click(function(e) {
$("#files").data("kendoUpload").trigger("cancel");
});
});
<input name="files" id="files" type="file" />
<button id="button">Cancel</button>
这篇关于单击按钮触发Kendo上传的OnCancel事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!