Is there a way to programmatically retrieve the currently selected file in Vault from vault.data or similar?
Hello @JHanawa ,
You can retrieve the file using getItem(id).
let selectedFileId = null;
...
const vault = new dhx.Vault("vault", {
...
eventHandlers: {
onclick: {
class_name: (_, id) => {
selectedFileId = id;
}
}
}
});
...
const getSelectedFile = () => {
return selectedFileId
? vault.data.getItem(selectedFileId)
: null;
};
Example:
Thank you for reply.
My apologies for the lack of explanation.
Is there a way to programmatically retrieve a list of selected files when multiple files are displayed in Vault and one or more files are selected?
I believe that using the eventHandler’s onclick method won’t handle cases where multiple files are selected using Shift, or when multiple files are already selected and one is selected, deselecting the others.
Hello @JHanawa ,
Unfortunately, Vault does not provide a public API for that at the moment.
However, a possible workaround is to use an internal selection API:
const selectedFiles = vault.list.selection.getItem();
Example:
Please note that this is an internal API and may change in future versions. As a result, the workaround may stop working.
Thank you for reply. I understand that this feature may become unavailable in the next version.
I sincerely hope that an API for retrieving selected files will be released in the next version.