We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to change the visible of filtertogglebutton in SfDataGrid - From 178541

I have 2 different column and both of them are allowing filtering. So, I have 2 filtertogglebutton in my view. And one of them must be visible all time but other one can change according to the situation. I tried do binding to visibility property of filtertogglebutton but it is affecting all buttons. How can I do that? 


1 Reply

VS Vijayarasan Sivanandham Syncfusion Team December 9, 2022 11:51 PM UTC

Hi Kivanc Yilmaz,

Your requirement to change the visibility of the filter toggle button in SfDataGrid can be achieved by customizing GridHeaderCellControl in the HeaderStyle property in GridColumn. Refer to the below code snippet,


<!--Here customize the GridHeaderCellControl to handle the filtericonvisibility for specific column-->

<Style x:Key="GridHeaderCellControlStyle" TargetType="{x:Type syncfusion:GridHeaderCellControl}">

            <Setter Property="Background" Value="Transparent" />

            <Setter Property="BorderBrush" Value="Gray" />

            <Setter Property="BorderThickness" Value="0,0,1,1" />

………………………………………

………………………………………

…………………………………….

<!--Here customize the Visibility based on your scenario-->

              <syncfusion:FilterToggleButton x:Name="PART_FilterToggleButton"

                                                          Grid.Column="2"                                               

                                                          HorizontalAlignment="Stretch"

                                                          VerticalAlignment="Stretch"

                                                          SnapsToDevicePixels="True"

                                                          Visibility="Collapsed" />

                                </Grid>

                            </Border>

 

                        </Grid>

                    </ControlTemplate>

                </Setter.Value>

            </Setter>

</Style>

 

<!--Here assign the customized HeaderStyle for specific column to handle the filtericonvisibility that column-->

                <syncfusion:GridTextColumn MappingName="CustomerName" HeaderStyle="{StaticResource GridHeaderCellControlStyle}"  HeaderText="Customer Name" />

 


UG Link: https://help.syncfusion.com/wpf/datagrid/styles-and-templates#styling-header-cell

Find the sample in the attachment.

Regards,

Vijayarasan S


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: Sample_41e8fd80.zip

Loader.
Up arrow icon