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. Image for the cookie policy date

IList binding and non-value-type properties

Does Essential Grid support arbitrary object types as properties when binding an IList to the data bound grid? Or is it limited to the common primitive/value types? For example, I have a list of account entry objects and the account entry object has a property called Payee which points to an IParty object. I'd like to display the Payee name in the grid and also allow the user to select from a list of common payees within the grid. I've tried just setting the property name "Payee" as the grid column's MappingName. I've also tried using "Payee.Name" to select the appropriate "sub-property". Is there an easy way of getting the Payee name into the grid via designer settings or do I have to resort to event processing for this scenario?

4 Replies

AD Administrator Syncfusion Team March 3, 2003 04:55 PM UTC

You could specify "ChoiceList" (or "GridListControl") as celltype, set the column's MappingName to "Payee" and the DisplayMember to the field that you want to display, e.g. "Name". You also need to have access to the collection with all the payees you want to display. Example: column.StyleInfo.CellType = "GridListControl"; column.StyleInfo.DisplayMember = "Name"; column.StyleInfo.DataSource = yourListWithAllPayees; column.StyleInfo.ValueMember = ""; // leave empty so that object ittself is stored and not a key that represents the object. Let me know if you run into any problems. Stefan


AI Apolon Ivankovic March 4, 2003 01:37 AM UTC

The settings you suggested result in the correct list of payee options for both a ComboBox or a GridListControl cell type, but the text for the payee name doesn't get displayed in the textbox portion of the cell. This is with ValueMember = ""; Interestingly if I use ValueMember = "." or set to null, then the cell does display the correct payee's name but in a "shadowed" font! What is the significance of the display of a shadowed font in a grid cell? I then added a "Self" property to the IParty interface which always returns the C# this. Setting ValueMember = "Self" now results in the correct payee name being displayed and in the expected font. This is not ideal, but works for the display side of things. Also, should I be able to use dot notation to bind a sub-property to a cell? I don't seem to be able to successfully do this. Thanks, Apolon.


AI Apolon Ivankovic March 4, 2003 06:06 AM UTC

I put together a smaller version of the application I'm working on to illustrate the object binding functionality. Now the smaller app. behaves as you indicated for ValueMember = ""; i.e. it does display the person/party name in the cells when the grid is first displayed. Can't find the difference between the two apps which results in the differing behaviour. I've still got problems with the setting actions, but this will be put in via DirectTrac. Thanks, Apolon.


AD Administrator Syncfusion Team March 4, 2003 08:28 AM UTC

Ok, thanks. I'll also review the combobox cell type source code again if there is anywhere a check for ValueMember = "" that might be wrong. But in general this should work without problem. Stefan

Loader.
Up arrow icon