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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Hiding Columns

Thread ID:

Created:

Updated:

Platform:

Replies:

127820 Dec 11,2016 04:19 AM UTC Dec 14,2016 05:37 AM UTC UWP 3
loading
Tags: SfDataGrid
Morgan
Asked On December 11, 2016 04:19 AM UTC

Is there a way to hide columns based on the screen using an AdaptiveTrigger,  I have tried by indexing the column, I have tried x:Name on the column.  VisualState is either not actually doing anything (which is not the question since I know the trigger is hitting). Or the Grid doesn't take the property change into account based on the screen size changing, when the State is hit and causes the setters to trigger the properties to be set.  This is slightly disturbing that you didn't add in "Visibility" properties that would be obvious over IsHidden?  I will try another solution to see if that will work over this failure.


<RelativePanel >
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="AdaptiveVisualStateGroup">
                    <VisualState x:Name="VisualStateNarrow">
                        <VisualState.StateTriggers>
                            <AdaptiveTrigger MinWindowWidth="{StaticResource NarrowMinWidth}" />
                        </VisualState.StateTriggers>
                        <VisualState.Setters>
                            <Setter Target="DocGrid.Columns[3].IsHidden" Value="True" />
                        </VisualState.Setters>
                    </VisualState>
                    <VisualState x:Name="VisualStateNormal">
                        <VisualState.StateTriggers>
                            <AdaptiveTrigger MinWindowWidth="{StaticResource NormalMinWidth}" />
                        </VisualState.StateTriggers>
                        <VisualState.Setters>
                            <Setter Target="DocGrid.Columns[3].IsHidden" Value="False" />
                        </VisualState.Setters>
                    </VisualState>
                    <VisualState x:Name="VisualStateWide">
                        <VisualState.StateTriggers>
                            <AdaptiveTrigger MinWindowWidth="{StaticResource WideMinWidth}" />
                        </VisualState.StateTriggers>
                        <VisualState.Setters>
                            <Setter Target="DocGrid.Columns[3].IsHidden" Value="False" />
                        </VisualState.Setters>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>

Jai Ganesh S [Syncfusion]
Replied On December 13, 2016 12:51 PM UTC

Hi Morgan, 
You can achieve your requirement to show/hide the columns based on the window width by using the below code. 
<Page.Resources> 
      <syncfusion:Columns x:Key="maxWidthColumns"> 
            <syncfusion:GridTextColumn HeaderText="UserId" MappingName="UserId" /> 
            <syncfusion:GridTextColumn HeaderText="Name" MappingName="Name" /> 
        </syncfusion:Columns> 
 
        <syncfusion:Columns x:Key="minWidthColumns"> 
            <syncfusion:GridTextColumn HeaderText="DateofBirth" MappingName="DateofBirth" /> 
            <syncfusion:GridTextColumn HeaderText="Salary" MappingName="Salary" /> 
        </syncfusion:Columns> 
</Page.Resources> 
 
<VisualStateManager.VisualStateGroups> 
            <VisualStateGroup x:Name="Screen"> 
                <VisualState> 
                    <VisualState.StateTriggers> 
                        <AdaptiveTrigger MinWindowWidth="700" /> 
                    </VisualState.StateTriggers> 
                    <VisualState.Setters> 
                        <Setter Target="sfGrid.Columns" Value="{StaticResource maxWidthColumns}" /> 
                    </VisualState.Setters> 
                </VisualState> 
 
                <VisualState> 
                    <VisualState.StateTriggers> 
                        <AdaptiveTrigger MinWindowWidth="0" /> 
                    </VisualState.StateTriggers> 
                    <VisualState.Setters> 
                        <Setter Target="sfGrid.Columns" Value="{StaticResource minWidthColumns}" /> 
                    </VisualState.Setters> 
                </VisualState> 
            </VisualStateGroup> 
        </VisualStateManager.VisualStateGroups> 

Regards, 
Jai Ganesh S 


Morgan
Replied On December 13, 2016 09:17 PM UTC

Excellent 

Thanks! Jai

Jai Ganesh S [Syncfusion]
Replied On December 14, 2016 05:37 AM UTC

Hi Morgan, 
Thank you for the update. 
Please let us know if you need further assistance on this. 
Regards, 
Jai Ganesh S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;