How to implement a discriminated union with each row bound to a different field of the data source?

Let's say I have a data source of items each with a type field string typeValue that can contains "String", "Int" and "Bool".  I have 3 fields string stringValue; int intValue; bool boolValue.

I want a grid with two columns "Type" bound to typeValue and a "Value" column bound to either stringValue, intValue or boolValue depending on the value in typeValue.

e.g. a four row grid:

"String", "This is a string value bound to stringValue."
"String", "This is another string."
"Bool", false             <-- displayed as a tickbox
"Int", 16000

How do I do this with the data bound grid?  I can see I need a bound column for the type and an dynamically bound column .  For each row I would dynamically set the binding and display properties depending on the type.  For example the boolean row above would change the cell to a tickbox and bind it to boolValue.


Is this possible?


1 Reply

KR Kannan R Syncfusion Team December 4, 2012 10:38 AM UTC

Hi Hamish,

 

Thanks for using Syncfusion products.

 

We have prepared sample based on your requirement and it can be downloaded from below location.

 

Sample Location: 105694ForumSample.zip

 

Please let us know if you have any queries.

 

Thanks,

Kannan.R


Loader.
Up arrow icon