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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Is there any way to align SfDataGrid as a centered in Grid or ContentView

Thread ID:

Created:

Updated:

Platform:

Replies:

149532 Nov 29,2019 01:58 AM UTC Dec 2,2019 02:05 PM UTC Xamarin.Android 3
loading
Tags: SfDataGrid
Xamarin Hunter
Asked On November 29, 2019 01:58 AM UTC

Maybe this is a very simple problem but I could not succeed this. My SfDataGrid could not be located centrally at horizontal and vertical in Grid or ContentView.

For Example: In a Grid;

            <ContentView Grid.Row="1" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                <syncfusion:SfDataGrid HorizontalOptions="Center" VerticalOptions="Center" AllowEditing="False" AllowResizingColumn="False" ColumnSizer="Auto"></syncfusion:SfDataGrid>
            </ContentView>

When I enter these codes, the data grid is not positioned horizontally and vertically. Every time, located according to the left side.

Balasubramani Sundaram [Syncfusion]
Replied On November 29, 2019 06:45 PM UTC

Hi Xamarin Hunter,  
 
Thank you for contacting Syncfusion support.   
 
Based on your provided code snippet we analyzed, if we set the column sizer to auto and LayoutOption to SfDataGrid, it will load at the center with minimum width and height measurements, you must set the MinimumWidthRequest to "0" to get the proper layout at the center. 
 
Please refer the below sample and code snippet,  
 
Code Snippet [C#] 
 
<ContentPage.Content> 
    <ContentView HorizontalOptions="FillAndExpand"  
                     VerticalOptions="FillAndExpand"> 
        <syncfusion:SfDataGrid  
                               ColumnSizer="Auto" 
                               HorizontalOptions="Center" 
                               VerticalOptions="Center" 
                               MinimumWidthRequest="0" 
                               AutoGenerateColumns="False" 
                               ItemsSource="{Binding OrdersInfo}"> 
            <syncfusion:SfDataGrid.Columns> 
                ....... 
                ....... 
                ....... 
            </syncfusion:SfDataGrid.Columns> 
        </syncfusion:SfDataGrid> 
    </ContentView> 
</ContentPage.Content> 
 
 
 
  
 
 
We hope this helps. Please let us know, if you need any further assistance. 
 
Regards,
Balasubramani Sundaram.
 
 


Xamarin Hunter
Replied On November 29, 2019 08:00 PM UTC

Hi Xamarin Hunter,  
 
Thank you for contacting Syncfusion support.   
 
Based on your provided code snippet we analyzed, if we set the column sizer to auto and LayoutOption to SfDataGrid, it will load at the center with minimum width and height measurements, you must set the MinimumWidthRequest to "0" to get the proper layout at the center. 
 
Please refer the below sample and code snippet,  
 
Code Snippet [C#] 
 
<ContentPage.Content> 
    <ContentView HorizontalOptions="FillAndExpand"  
                     VerticalOptions="FillAndExpand"> 
        <syncfusion:SfDataGrid  
                               ColumnSizer="Auto" 
                               HorizontalOptions="Center" 
                               VerticalOptions="Center" 
                               MinimumWidthRequest="0" 
                               AutoGenerateColumns="False" 
                               ItemsSource="{Binding OrdersInfo}"> 
            <syncfusion:SfDataGrid.Columns> 
                ....... 
                ....... 
                ....... 
            </syncfusion:SfDataGrid.Columns> 
        </syncfusion:SfDataGrid> 
    </ContentView> 
</ContentPage.Content> 
 
 
 
  
 
 
We hope this helps. Please let us know, if you need any further assistance. 
 
Regards,
Balasubramani Sundaram.
 
 


Thank you for your answer. I've tried the code block instance you mentioned; When I compile the application, a problem occurs: the datagrid is located in the center but then, it is placed to the left. I don't understand this problem. Here is my code:

            <ContentView Grid.Row="6" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                <syncfusion:SfDataGrid MinimumWidthRequest="0" HorizontalOptions="Center" VerticalOptions="Center" BackgroundColor="Transparent" AllowEditing="False" AllowResizingColumn="False" ColumnSizer="Auto" AutoGeneratingColumn="MyAlter_AutoGeneratingColumn"></syncfusion:SfDataGrid>
            </ContentView>



Balasubramani Sundaram [Syncfusion]
Replied On December 2, 2019 02:05 PM UTC

Hi Utemar, 
 
Thanks for the update.     
 
We have tried your code snippet in our earlier provided sample, in that instead of creating a column manually we have AutoGenerated them and in AutoGeneratingColumn event we have done some customization then also it is working fine as we expected. 
 
Please refer the sample and code snippet,  
 
Code Snippet [C#] 
 
[MainPage.Xaml] 
 
<ContentPage.Content> 
    <ContentView HorizontalOptions="FillAndExpand"  
                 VerticalOptions="FillAndExpand"> 
        <syncfusion:SfDataGrid  
                           x:Name="myGrid"   
                           ColumnSizer="Auto" 
                           HorizontalOptions="Center" 
                           VerticalOptions="Center" 
                           MinimumWidthRequest="0" 
                           AllowResizingColumn="False" 
                           AutoGenerateColumns="True" 
                           AutoGeneratingColumn="myGrid_AutoGeneratingColumn" 
                           ItemsSource="{Binding OrdersInfo}"> 
        </syncfusion:SfDataGrid> 
    </ContentView> 
</ContentPage.Content> 
 
 
 
 
 
Android  
 
 
 
UWP 
 
 
 
Note: Issue has been checked with Xamarin. Forms version 3.6 and Syncfusion NuGet version 17.3.0.28 
    
Please check the sample and let us know if you still facing the same issue? If not, please modify the sample based on your scenario and revert us with the more details, so that it will be helpful for us to check on it and provide you the solution at the earliest.    
 
Regards,
Balasubramani Sundaram.
 
 


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

This page will automatically be redirected to the 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

Live Chat Icon For mobile
Live Chat Icon