Remove Filter button for ONLY one column
Hi, I'd like to remove/hide the 'Filter' button for ONLY one column in my data grid. For all other columns, I want to keep the 'Filter' button.
For example:
BEFORE:
AFTER:
Question:
How do I remove the 'Filter' button for ONLY one column?
Thank you
SIGN IN To post a reply.
1 Reply
VN
Vignesh Natarajan
Syncfusion Team
July 5, 2021 03:40 AM UTC
Hi Kenney,
Thanks for the update.
Query: “ I'd like to remove/hide the 'Filter' button for ONLY one column in my data grid. For all other columns, I want to keep the 'Filter' button.”
We have analyzed your query and we suggest you to hide the Filter button in Menu Filter for that particular column using the below solution. OnActionBegin event will be triggered when certain action is initiated. So while opening the Filter dialog, OnActionBegin will be triggered with RequestType FilterBeforeOpen. Here we can to add custom style to document to hide the Filter button textbox for that particular column.
Refer the below code example
|
@using Syncfusion.Blazor.Grids
<SfGrid DataSource="@Orders" AllowPaging="true" AllowFiltering="true">
<GridEvents OnActionBegin="OnActionBegin" TValue="Order"></GridEvents>
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
@if (CanAdd)
{
<style>
.e-grid .e-filter-popup .e-footer-content .e-flmenu-okbtn {
display: none;
}
</style>
}
@code{
public List<Order> Orders { get; set; }
public bool CanAdd { get; set; }
public void OnActionBegin(ActionEventArgs<Order> Args)
{
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.FilterBeforeOpen)
{
if (Args.ColumnName == "CustomerID")
{
CanAdd = true;
}
else
{
CanAdd = false;
}
}
}
|
For your convenience we have prepared a sample using above code example which can be downloaded from below
Refer our UG documentation for your reference
Please get back to us if you have further queries.
Regards,
Vignesh Natarajan
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
KP Kenney Phan
- Jul 2, 2021 11:55 PM UTC
- Jul 5, 2021 03:40 AM UTC