Custom toolbar option to be visible only when a file is selected

Hi Syncfusion Team,

Currently, a custom toolbar option is visible at all times, regardless of when a file is selected or not. However, we only want the custom toolbar option to be only visible when a file is selected. Can you provide a sample code or a snippet on how we can achieve that please?

By custom toolbar option, I mean the toolbar options that are added to the FileManager together with the default toolbar options via the Items property from the FileManagerToolbarSettings class.

Thanks 


1 Reply 1 reply marked as answer

SM Shalini Maragathavel Syncfusion Team September 16, 2021 01:54 PM UTC

Hi Denzel, 

Greetings from Syncfusion support.
 
Based on your query, we could understand that you need to show/hide the custom toolbar item based on the selected files in the File Manager. You can achieve your requirement by updating the toolbar items in the FileSelection event of File Manager as demonstrated in the below code snippet. 
 
  <SfFileManager TValue="FileManagerDirectoryContent"> 
        <FileManagerToolbarSettings Items="@Items"></FileManagerToolbarSettings> 
        <FileManagerEvents FileSelection="FileSelection"></FileManagerEvents> 
    </SfFileManager> 
@code  { 
    public void FileSelection(FileSelectionEventArgs<FileManagerDirectoryContent> args) 
    { 
        if (args.Action == "Select") 
        { 
            Items = new string[] { "NewFolder", "Upload", "Delete", "Download", "Rename", "SortBy", "Refresh", "Selection", "View", "Details", "Custom" }; 
        } 
        else if(args.Action == "UnSelect") 
        { 
            Items = new string[] { "NewFolder", "Upload", "Delete", "Download", "Rename", "SortBy", "Refresh", "Selection", "View", "Details"}; 
 
        } 
    } 
} 

Please find the below sample for your reference.
 
  
 
API Link: https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.FileManager.FileSelectionEventArgs-1.html

Please get back to us if you need any further assistance.  
 
Regards, 
 
Shalini M. 


Marked as answer
Loader.
Up arrow icon