我已经通过使用 CSS 禁用 Dropzone 控件解决了这个问题。
.maxFilesReached {
pointer-events: none;
cursor: default;
background-color: #ffd9d8
}
这个 CSS 类在成功时被添加到 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 类在 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 属性来防止多次上传。
附: jsGrid 有点乱。