Hy,
I have a custom toolbar button in FileManager. This button should be visible when any files are selected in FileManager and should be invisible when there are no selected files (similar as the built-in Delete button).
I try use fileSelect event:
@{
string[] items = new string[] { "Delete", "Download", "SortBy", "Refresh", "Selection", "View", "Details", "Custom" };
string[] layout = new string[] { "SortBy", "View", "Refresh", "|", "Details", "|", "SelectAll" };
string[] fileop = new string[] { "Delete", "Download", "|", "Details" };
}
<ejs-filemanager id="filemanager" view="Details"
created="onFileManagerCreated"
fileLoad="onFileLoad"
beforeSend="onBeforeSend"
toolbarClick="toolbarClick"
toolbarCreate="onCreate"
fileSelect="selectionChanged">
<e-filemanager-ajaxsettings url="https://localhost:7042/api/FileManager/FileOperations"
downloadUrl="https://localhost:7042/api/FileManager/Download"
uploadUrl="https://localhost:7042/api/FileManager/Upload"
getImageUrl="https://localhost:7042/api/FileManager/GetImage">
</e-filemanager-ajaxsettings>
<e-filemanager-toolbarsettings items="items">
</e-filemanager-toolbarsettings>
<e-filemanager-contextmenusettings file="fileop" layout="layout">
</e-filemanager-contextmenusettings>
</ejs-filemanager>
<script>
function selectionChanged(args) {
const fileManagerInstance = $('#filemanager').get(0).ej2_instances[0];
const selectedItems = fileManagerInstance.selectedItems;
console.log("Selected Items:", selectedItems);
}
The problem is, that the selectedItems collection is not updated now in this selectionChanged(args) method, so it returns the previous value (-1).
My question is:
- Which event can I use for get selected items count?
Thank you!
Hi, thank you very much its working now in my project too.
Glad to hear that the solution works for you.