Hello
I have a few questions regarding data binding on the XamDataGrid.
Lets say I set the DataSource to be an object of type List<Item> where Item is a class that has a number of public properties.
I want to add two extra columns in the grid:
1. The first column is simply a row counter and shows the number of the row. It has nothing to do with the Item class. I simply want an extra column called "Item Number" where each cell takes it's value from the grid.Row.Index (or whatever grid property gives me the row index).
2. The second column is an unbound column (i.e. not a public property in the Item class) that has the value calculated by applying a formula on the values of other cells in that row (i.e. public properties on Item). For example, I want a column called "Net Price" where the value is calculated by getting the Item.Price and multiplies it with the Item.Quantity.
Could someone explain to me how I can do this? Could you please provide me with code examples on exactly what events I have to override on the grid (or any of it's properties) to achieve this?
I can set the
XamDataGrid.FieldLayoutSettings.AutoGenerateFields = false
and then override the
XamDataGrid.FieldLayoutInitialized
event and programatically create the Fields (side-question: is Field the equivalent of Column in the WinForms UltraGrid??), but I do not really understand how to achieve 1. and 2. above.
Many thanks
Kostas
Looking at the sample, I could not get a way where the the unbound column gets updated with the dependent fields in case of dynamic data.
I am looking for the capability to add custom calculated columns to the grid. e.g.
Predefined Columns:
Column 1 --> Quantity
Column 2 --> Price
Custom Column(s):
Column 3 --> Amount --> Column 1 * Column2 (Quantity * Price)
The main requirement is that the column 1 & column 2 are having dynamic values getting updated.
Also, the calculating formula can be changed on the runtime and is not to be hard-coded.
Kindly let me know if the xamDataGrid exposes any way to achieve this and if so, which version onwards.
And, if not natively supported, any suitable workarounds would also be helpful.
- Mayank
Hi Kostas,
If you have our samples installed, you can open Feature Browser. There is a sample xamDataGrid -> Data Binding and Interactions -> UnboundFields, which shows how to add unbound fields and to modify the data in them. Hope this helps.
Thanks,
Diyan Dimitrov