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

DisplayMemberPath not working with Arrays

Thread ID:

Created:

Updated:

Platform:

Replies:

141043 Nov 20,2018 10:29 AM UTC Nov 22,2018 04:23 AM UTC Xamarin.Forms 3
loading
Tags: SfComboBox
Thomas Loidolt
Asked On November 20, 2018 10:29 AM UTC

Hi,

I want to add a list of classes at the DataSource and the class has a string[] property with name "Entries".
For example in the SfDataGrid I add as MappingName = "Entries[0]" and the Cell references to  any_object.Entries[0].

I hoped that it works simliar to DisplayMemberPath but I got not the same successful result.

Does anybody has a hint?

My code:

...

_comboBox = new SfComboBox();


_comboBox.IsEditableMode = false;

_comboBox.MaximumDropDownHeight = 200;

_comboBox.HeightRequest = 40;

Entries = new ObservableCollection<SelectionViewEntry>();


_comboBox.DataSource = this.Entries;

_comboBox.DisplayMemberPath = "Entries[0]";


...


public class SelectionViewEntry

{

public string[] Entries { get; set; }

}



Paul Anderson S [Syncfusion]
Replied On November 21, 2018 12:07 PM UTC

Hi Thomas Loidolt, 
 
Greetings from Syncfusion. 
 
We checked the given code snippet and when using String [] type for the data source it returns only the array object. We have also tested the same String [] type data with the ListView control and it also returned only the array object. We have prepared a sample on how to use a collection of a custom class and display the desired property using DisplayMemberPath. Please find the sample from the below link. 
 
 
For more information about using “DisplayMemberPath” property is given below: 
 
 
Please check our sample and let us know if you have any concerns. 
 
Regards, 
Paul Anderson 


Thomas Loidolt
Replied On November 21, 2018 03:40 PM UTC

Hi,

your solution is not working for my requirements but I found another way to solve it:

public class SelectionViewEntry
{
public int ColumnIndex { get; set; }
public string Entry { get => Entries[ColumnIndex]; set => Entries[ColumnIndex] = value; }
public string[] Entries { get; set; }
}

And this is a working example of SfDataGrid and MappingName:

_dataGrid.Columns.Add(new GridTextColumn() { MappingName = "Features[" + i.ToString() + "]", HeaderText = item.Value.Value, TextAlignment = item.Value.HorizontalAlignment, FontAttribute = FontAttributes.Bold });

BR,Thomas

Paul Anderson S [Syncfusion]
Replied On November 22, 2018 04:23 AM UTC

Hi Thomas, 
  
Thanks for the update. We are glad that you have achieved your requirement. Please get in touch if you required further assistance. 
  
Regards, 
Paul Anderson 


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