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
close icon

How do i turn off the headings of the grid, have the columns auto size and the background be transparent

How do I turn off the headings of the grid, have the columns auto size and the background be transparent?  Below is the code I am trying. 

            <syncfusion:SfDataGrid x:Name="dgRatings" AutoGenerateColumns="False" Grid.Row="2" Grid.Column="0" BackgroundColor="Transparent"
                                   HorizontalOptions="CenterAndExpand" VerticalOptions="StartAndExpand" ColumnSizer="Auto"   >
                <syncfusion:SfDataGrid.Columns x:TypeArguments="syncfusion:Columns">
                    <syncfusion:GridTemplateColumn MappingName="DOWName" ColumnSizer="Auto" >
                        <syncfusion:GridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Label Text="{Binding DOWName}" TextColor="Black" HorizontalOptions="EndAndExpand" VerticalOptions="Center" FontSize="Large" />
                            </DataTemplate>
                        </syncfusion:GridTemplateColumn.CellTemplate>
                    </syncfusion:GridTemplateColumn>
                    <syncfusion:GridTextColumn MappingName="Rating" ColumnSizer="Auto"/>
                </syncfusion:SfDataGrid.Columns>
            </syncfusion:SfDataGrid>

I get a white background with the column name from the ViewModel as the column heading and the rows are sized to the column heading instead of the column content.  Any assistance would be appreciated.  Also - anyone who can point me to good samples for the grid, I would appreciate it.


4 Replies

DS Divakar Subramaniam Syncfusion Team November 9, 2016 10:48 AM UTC

Hi George, 
 
 
Thanks for contacting Syncfusion Support. 
 
 
We have checked your query. Since we have applied background color for the rows, it will only reflects in the view even if you set background color for the grid. Hence, if you need to apply the transparent color to the grid then you can achieve it by applying background color to the grid records as in below code snippet. 
 
//In code behind 
dataGrid.GridStyle = new CustomGridStyle(); 
 
//CustomGridStyle class 
public class CustomGridStyle : DataGridStyle 
{ 
 
    public override Color GetRecordBackgroundColor()  
    { 
        return Color.Transparent; 
    } 
} 
 
If you want to show the custom column header instead of view model property as column header, then you can achieve it by setting GridTemplateColumn.HeaderText property as in below code snippet. 
 
<syncfusion:GridTemplateColumn ColumnSizer="Auto" 
                               HeaderText="CustomHeader" 
                               MappingName="CustomerID"> 
 
If you set GridColumn.ColumnSizer property as “Auto”, then the column will be adjusted based on the large cell content whether the content is in header or in cell. The columns are adjusted properly based on the content loaded on our side. 
 
 
We have prepared a sample as you required and you can download the same from the below link. 
 
 
 
Regards, 
Divakar. 



GC George Ceaser November 9, 2016 01:10 PM UTC

The only thing this sample fixes is the Background.  It still shows headers and the columns do not auto size on the WinPhone 8.1 project.  I would post an image but this site will not let me upload an image and I do not have a web site to post it on.  Below is the code I changed in your sample to test the column widths.  The column headings always showed from the first time I ran it.  All I did was put some large static text in the Label inside the data template

  <syncfusion:SfDataGrid x:Name="dataGrid"
                           AutoGenerateColumns="False"
                           BackgroundColor="Transparent"
                           ColumnSizer="Auto"
                           ItemsSource="{Binding OrdersInfo}">
        <syncfusion:SfDataGrid.Columns x:TypeArguments="syncfusion:Columns">
            <syncfusion:GridTemplateColumn ColumnSizer="Auto"
                                           HeaderText="CustomHeader"
                                           MappingName="CustomerID">
                <syncfusion:GridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <Label FontSize="Large"
                               HorizontalOptions="EndAndExpand"
                               Text="This is a test of some very large text"
                               TextColor="Black"
                               VerticalOptions="Center" />
                    </DataTemplate>
                </syncfusion:GridTemplateColumn.CellTemplate>
            </syncfusion:GridTemplateColumn>
            <syncfusion:GridTextColumn ColumnSizer="Auto" MappingName="OrderID" />
        </syncfusion:SfDataGrid.Columns>
    </syncfusion:SfDataGrid>


GC George Ceaser November 10, 2016 02:13 PM UTC

Any status on getting a sample that actually resolves the challenges of not showing any header and have the columns correctly autosize?


AN Ashok N Syncfusion Team November 11, 2016 04:56 AM UTC

Hi George,   
  
We have analyzed your query and currently we don’t have support for TableSummaryRow in Xamarin. A support incident has been created under your account. Please log on to our support website to check for further updates:    
     
    
Regards,    
Ashok

Loader.
Live Chat Icon For mobile
Up arrow icon