This is a migrated thread and some comments may be shown as answers.

ItemDisplayBindingPath + NullReferenceException

1 Answer 96 Views
DataGrid
This is a migrated thread and some comments may be shown as answers.
Travis
Top achievements
Rank 1
Travis asked on 09 Sep 2019, 04:46 PM

I am attempting to use a DataGridPickerColumn. I am able to get my source list to show up and also have it bind to my property, but whenever I use the ItemDisplayBindingPath, the app is crashing with a null reference exception. Whenever I take out ItemDisplayBindingPath, I do not get the exception. My ProductModel class and the XAML I am using is below:

 

public class ProductModel
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Units { get; set; }
}

 

<tkDataGrid:DataGridPickerColumn ItemsSource="{Binding BindingContext.Data.ProductModels, Source={x:Reference schedulePage} }" ItemDisplayBindingPath="Name" PropertyName="Product" HeaderText="Product" />

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 11 Sep 2019, 11:28 AM

Hi Travis,

I've tested the scenario and managed to reproduce the exception - it seems there is an issue in RadDataGrid in the case the ItemsSource of the PickerColumn is bound to a collection not part of the business object. I logged the issue on your behalf in our public feedback portal, you could track its status and get notified on status changes at the link below:

DataGrid: NullReferenceException is thrown when ItemsSource of the PickerColumn is bound to an external source

There isn't a direct workaround I could suggest for the concrete setup - the options that come to my mind are:

  • Use DataGridTemplateColumn instead of the PickerColumn and manually add a Picker control. Keep in mind that the TemplateColumn has some limitations such as missing filtering feature. Check the following article for more details on this: DataGrid TemlateColumn.
  • Use ItemsSourcePath property of the PickerColumn, this, however, will require adding the ProductModels collection as a property of the business objects used as ItemsSource of the DataGrid.  Please check the exact implementation here: DataGrid Columns Example.

I am sorry for any inconvenience caused.

Regards,
Yana
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DataGrid
Asked by
Travis
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or