[英]How to upload and display only one file in Dropzone.js and jsGrid?
我已经通过使用 CSS 禁用 Dropzone 控件解决了这个问题。
.maxFilesReached {
pointer-events: none;
cursor: default;
background-color: #ffd9d8
}
此 CSS class 在成功时添加到 jsGrid loadData
事件。
loadData: function (filter) {
return $.ajax({
type: "POST",
url: "/Downloads/GetDownloadItems/" + DownloadId,
data: filter,
dataType: "json"
}).done(function (response) {
debugger;
if (response.length == 1) { // disabling Dropzone control
$("#dropzoneForm").addClass('maxFilesReached');
}
});
}
同样,CSS class 在 jsGrid 的deleteItem
事件时被删除。
deleteItem: function (item) {
return $.ajax({
type: "POST",
url: "/Downloads/DDownloadItem/" + item.Id,
dataType: "json"
}).done(function () {
// enabling Dropzone control
$("#dropzoneForm").removeClass('maxFilesReached');
});
}
我还使用了 Dropzone 的maxFiles
属性来防止多次上传。
PS jsGrid 有点乱。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.