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

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

Thread ID:

Created:

Updated:

Platform:

Replies:

127330 Nov 9,2016 02:14 AM UTC Nov 11,2016 04:56 AM UTC Xamarin.Forms 4
loading
Tags: SfDataGrid
George Ceaser
Asked On November 9, 2016 02:14 AM UTC

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.


Divakar Subramaniam [Syncfusion]
Replied On 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. 


George Ceaser
Replied On 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>

George Ceaser
Replied On 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?

Ashok N [Syncfusion]
Replied On 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

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.

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

;