SfDataGrid.View is null

I create data grid like this.
            dataGrid = new SfDataGrid
            {
                ItemsSource = App.Items,
                AutoGenerateColumns = false,
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,

                ColumnSizer = ColumnSizer.Star,
                AlternationCount = 2              
            };
            dataGrid.GridStyle.AlternatingRowColor = Color.LightGreen;
            dataGrid.View.LiveDataUpdateMode = LiveDataUpdateMode.AllowSummaryUpdate;

where App.Items is ObservableCollection<MyItem>, so very basic example. Issue is that View property is always null, so this line: dataGrid.View.LiveDataUpdateMode = LiveDataUpdateMode; fails.
Otherwise code works as intended.
Is this a bug or I missed some steep ?

Thank you

3 Replies

SK Shivagurunathan Kamalakannan Syncfusion Team December 18, 2017 12:38 PM UTC

Hi Bostjan Primozic, 
 
Thanks for contacting Syncfusion Support. 
 
We have checked your query and the given code example.  
 
SfDataGrid.View related properties can be used only after creating SfDataGrid.View. Hence changes related to View can be done only in SfDataGrid.GridViewCreated or SfDataGrid.GridLoaded event or in the runtime only. 
 
Refer the below link for more details regarding the SfDataGrid.View. 
 
Refer the below code for reference: 
 
public partial class MainPage : ContentPage 
{ 
    public MainPage() 
    { 
        InitializeComponent(); 
        dataGrid.GridStyle.AlternatingRowColor = Color.LightGreen; 
        dataGrid.GridViewCreated += DataGrid_GridViewCreated; 
    } 
 
    private void DataGrid_GridViewCreated (object sender, GridViewCreatedEventArgs e) 
    { 
        dataGrid.View.LiveDataUpdateMode = LiveDataUpdateMode.AllowSummaryUpdate; 
    } 
} 
 
We have prepared a sample for your reference and you can download the same from below link. 
 
 
 
Regards, 
Shivagurunathan. K 
 



BP Bostjan Primozic December 18, 2017 11:14 PM UTC

It works now, thank you.


SK Shivagurunathan Kamalakannan Syncfusion Team December 19, 2017 04:04 AM UTC

Hi Bostjan Primozic, 
Thanks for contacting Syncfusion Support.  
Please let us know if you require any further assistance. 
  
Regards, 
Shivagurunathan. K 
 


Loader.
Up arrow icon