How to access path property for custom context menu and custom toolbar options

Hi,

I am trying to create a custom context menu option and a custom toolbar option to open a file from the file manager component within the document editor component. Whilst creating the custom options is straight forwards I am finding it difficult to access the path property so that I can pass the details of the path through to the document editor component. If I override the beforeDownload method it has access to the path. Does anyone know how to access the path through a custom method?

Many Thanks

Matt


1 Reply

IL Indhumathy Loganathan Syncfusion Team September 20, 2022 09:59 AM UTC

Hi Matt,


Greetings from Syncfusion support.


Yes, you can add a custom button in both Toolbar and Context Menu of the File Manager component. The toolbar items can be customized using the toolbarSettings API and toolbarClick events. The context menu can be customized using the contextMenuSettingsmenuOpen, and menuClick events.
You can refer to the below documentation to achieve this requirement.


https://ej2.syncfusion.com/angular/documentation/file-manager/how-to/adding-custom-item-to-toolbar/


https://ej2.syncfusion.com/angular/documentation/file-manager/how-to/adding-custom-item-to-context-menu/


You can retrieve the path value inside the File Manager within the toolbarClick and menuClick as shown below.


  toolbarClick(args) {

    if (args.item.text === 'Custom') {

      var fullPath = this.fileObj.path + this.fileObj.selectedItems;

      alert('You have clicked custom toolbar item and path is ' + fullPath + '.');

    }

  }

  menuClick(args) {

    if (args.item.text === 'Custom') {

      var fullPath = this.fileObj.path + this.fileObj.selectedItems;

      alert('You have clicked custom menu item and path is ' + fullPath + '.');

    }

  }


Sample: https://stackblitz.com/edit/react-whqvv9?file=index.js,index.css,index.html


We would also like to share that we have prepared a sample to open the following extension file (pdf, docx, xlsx, txt) in the File Manager by using PDF Viewer, DocumentEditor and SpreadSheet components. You can refer to the below link to achieve the same.


https://www.syncfusion.com/forums/154689/how-to-integrate-pdfviewer-to-preview-pdf-files-on-the-file-explorer-component?reply=NqZPuM


Please check the shared details and get back to us if you need any further assistance.


Regards,

Indhumathy L


Loader.
Up arrow icon