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

How to display RowIndex at RowHeaderCell in SfDataGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

147370 Sep 8,2019 04:24 AM UTC Sep 9,2019 11:56 AM UTC Xamarin.Forms 1
loading
Tags: SfDataGrid
Abhishek Singhal
Asked On September 8, 2019 04:24 AM UTC

Using Xamarin Forms, how to display RowIndex at RowHeaderCell in SfDataGrid programmatically.

Thanks

Shivagurunathan Kamalakannan [Syncfusion]
Replied On September 9, 2019 11:56 AM UTC

Hi Abhishek,   
    
Thank you for contacting Syncfusion support.   
    
Your requirement “To show the row index in the row header cell programmatically” can be achieved by using RowHeaderTemplate in SfDataGrid.    
    
Please refer the below code.    
    
public partial class MainPage : ContentPage   
{   
              SfDataGrid dataGrid;   
              ViewModel viewModel;   
              public MainPage()   
              {   
                             InitializeComponent();   
                             dataGrid = new SfDataGrid();   
                             viewModel = new ViewModel();   
                             this.BindingContext = viewModel;   
                             dataGrid.ColumnSizer = ColumnSizer.Star;   
                             dataGrid.ItemsSource = viewModel.OrdersInfo;   
                             dataGrid.ShowRowHeader = true;   
                             dataGrid.AutoGeneratingColumn += DataGrid_AutoGeneratingColumn;   
                             dataGrid.RowHeaderTemplate = new DataTemplate(() =>   
                             {   
                                           var label = new Label();   
                                           label.SetBinding(Label.TextProperty, new Binding("Index", BindingMode.Default, null, null, null, null));   
                                           return label;   
                             });   
                             this.Content = dataGrid;   
              }   
              private void DataGrid_AutoGeneratingColumn(object sender, AutoGeneratingColumnEventArgs e)   
              {   
                             if (e.Column.MappingName == "Index")   
                                           e.Cancel = true;   
              }   
}                
                 
 
  
Please refer the following KB for more details. 
    
We have prepared a sample based on your requirement and it can be downloaded from the below link.   
   
Regards,   
Shivagurunathan   


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