I have somethng like that
<SfGrid DataSource="@Orders" @ref="Grid">
<GridTemplates>
<ToolbarTemplate>
<SfToolbar>
<ToolbarEvents Clicked="ToolbarClickHandler"></ToolbarEvents>
<ToolbarItems>
<ToolbarItem Type="@ItemType.Button" PrefixIcon="e-chevron-up icon" Id="collapseall" Text="Collapse All"></ToolbarItem>
<ToolbarItem Type="@ItemType.Button" PrefixIcon="e-chevron-down icon" Id="ExpandAll" Text="Expand All"></ToolbarItem>
</ToolbarItems>
</SfToolbar>
</ToolbarTemplate>
</GridTemplates>
</SfGrid>Ho can i enable/disable buttons ?
OK
I wasn't able to use
EnableToolbarItems, but I was able to disable it by reference.
Is this the only and correct method?
Hi Tomasz,
Greetings from Syncfusion.
We would like to inform you that EnableToolbarItems method will work only for inbuilt toolbar items. So we recommend you to use Disable property of toolbar item to dynamically disable or enable the toolbar item.
|
<SfButton @onclick=@Disable>Enable/Disable</SfButton>
<SfGrid DataSource="@Orders" AllowPaging="true" Height="200" @ref="Grid" AllowGrouping="true"> <GridTemplates> <ToolbarTemplate> <SfToolbar> <ToolbarEvents Clicked="ToolbarClickHandler"></ToolbarEvents> <ToolbarItems> <ToolbarItem Disabled=@disable Type="@ItemType.Button" PrefixIcon="e-chevron-up icon" Id="collapseall" Text="Collapse All"></ToolbarItem> <ToolbarItem Type="@ItemType.Button" PrefixIcon="e-chevron-down icon" Id="ExpandAll" Text="Expand All"></ToolbarItem> </ToolbarItems> </SfToolbar> </ToolbarTemplate> </GridTemplates> <GridGroupSettings Columns=@GroupOption></GridGroupSettings> <GridColumns> </GridColumns> </SfGrid> @code { public bool disable { get; set; } = false; private SfGrid<OrderData> Grid; public List<OrderData> Orders { get; set; } private string[] GroupOption = (new string[] { "OrderID" });
public void Disable() { if(disable) { disable = !disable; } else { disable = true; } } public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args) { if (args.Item.Text == "Collapse All") { this.Grid.CollapseAllGroupAsync(); } if (args.Item.Text == "Expand All") { this.Grid.ExpandAllGroupAsync(); } }
|
Please let us know if you have any concerns.
Regards,
Monisha
Hi Tomasz,
We are glad to hear that the reported issue has been resolved at your end. Kindly get back to us if you have further queries. As always we will be happy to assist you.
Regards,
Monisha