When using EJ2 (23.2.4) FileManager I'm trying to set its path client-side, once the component has loaded. Say that I want it to load the '/Root/My Path/Folder/' path.
I've found 2-3-ish options, but none are working as expected:
fileManager.path = '/Root/My Path/Folder/'will trigger an error in the console saying "Cannot read properties of null (reading 'querySelector')", which it seems to come from somewhere within EJ2. The component now shows a spinner icon and seems to hang. When I do
fileManager.path = '/', it goes to the root path and goes out of its "hanging" state. If I do
fileManager.path = '/Root/My Path/Folder/'and *then* I do
fileManager.refreshFiles()then it loads only the first folder ('Root'), not without triggering that JS error mentioned before - and if at this step I ran
fileManager.refreshFiles()once more, it goes to the root folder.
fileManager.openFile('/Root/My Path/Folder/') won't work. I need to pass just one directory (without the slashes) to this method at at time to make it work, i.e. fileManager.openFile('Root'), then fileManager.openFile('My Path') and then fileManager.openFile('Folder'). The documentation mentions "If you want to open the nested level folder or file, then specify the filter path along with name of the folder or file when performing search or custom filtering." - but I just can't make any sense of what does this mean exactly.fileManager.ajaxSettings.url = '/Root/My Path/Folder/'throws an error about an invalid JSON response. I tried passing manually the internal path to it (the one that looks like '/root/my_path/folder/'), but that won't be possible from frontend - and still it just loads the very first folder, '/root'.
Any clear indication about how to make this work will be appreciated.
Hi acidrums,
Thank you for reaching out.
We understand you're trying to set a nested folder path (e.g., /Root/My Path/Folder/) in the EJ2 FileManager component from the client side but encountered issues with path navigation and JavaScript errors.
We have reviewed your scenario and would like to confirm that setting the path during the initial configuration of the FileManager (i.e., before rendering) is the recommended and supported approach. This method successfully loads the desired folder without requiring manual calls like refreshFiles() or step-by-step openFile() navigation.
For example, setting the path as shown below resolves the issue:
|
// initialize File Manager Control var filemanagerInstance = new ej.filemanager.FileManager({ ajaxSettings: { url: hostUrl + 'api/FileManager/FileOperations', getImageUrl: hostUrl + 'api/FileManager/GetImage', uploadUrl: hostUrl + 'api/FileManager/Upload', downloadUrl: hostUrl + 'api/FileManager/Download', }, path: '/Picture/Food', }); |
For your reference we attached a sample.
Sample : https://stackblitz.com/edit/ap7tstmx-lkazmomm?file=index.html
If you need any further assistance or have additional queries, please feel free to let us know.
Regards,
saravanan J