Disable custom toolbar

How to disable the other custom toolbar like PDF Export, Excel Export and Archive just like the Add, Edit, Delete when I click the EditDate custom toolbar?Screenshot (427).png


1 Reply

VN Vignesh Natarajan Syncfusion Team November 26, 2021 08:13 AM UTC

Hi Belle, 
 
Thanks for contacting Syncfusion support.  
 
Query: “How to disable the other custom toolbar like PDF Export, Excel Export and Archive just like the Add, Edit, Delete when I click the EditDate custom toolbar?” 
 
We suggest you to achieve your requirement using EnableToolbarItemsAsync method of Grid. Refer the below code example.  
 
<SfGrid ID="Grid" @ref="GridInstance" DataSource="@Orders" AllowPaging="true" AllowExcelExport="true" AllowPdfExport="true" Toolbar="@Toolbaritems"> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings> 
    <GridEvents OnToolbarClick="ToolbarClicked" TValue="Order"></GridEvents> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" EditType="EditType.DatePickerEdit" Format="d" TextAlign="TextAlign.Right" Width="130" Type="ColumnType.Date"></GridColumn> 
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
    </GridColumns> 
</SfGrid> 
  
  
@code{ 
    SfGrid<Order> GridInstance { getset; } 
    public List<Order> Orders { getset; } 
    private List<Object> Toolbaritems = new List<Object>() { "Add""Edit"new ItemModel() { Text = "EditDate", TooltipText = "EditDate", Id = "editdate" }, "Delete""Update""Cancel""PdfExport""ExcelExport"new ItemModel() { Text = "Archive", TooltipText = "Archive", Id = "Archive" } }; 
  
    public async Task ToolbarClicked(Syncfusion.Blazor.Navigations.ClickEventArgs Args) 
    { 
        if (Args.Item.Id == "Grid_pdfexport")  //Id is combination of Grid's ID and itemname 
        { 
            await this.GridInstance.PdfExport(); 
        } 
        if (Args.Item.Id == "Grid_excelexport"//Id is combination of Grid's ID and itemname 
        { 
            await this.GridInstance.ExcelExport(); 
        } 
        if (Args.Item.Id == "editdate") 
        { 
            await GridInstance.EnableToolbarItemsAsync(new List<string>() { "PdfExport",  "Archive""ExcelExport" }, false); 
        } 
    } 
 
 
Refer the below sample for your reference 
 
 
Kindly get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan  


Loader.
Up arrow icon