I have a UltraGrid which has several columns with UltraDropDown controls set as the ValueList.
These columns are ID fields. As an example, one dropdown contains for an ID, an Order #, a Customer name, and a Delivery Date. DisplayMember is Order # and Valuemember is ID, Customer name and Delivery Date are shown when the dropdown is open.
This grid has several unbound columns. Continuing my example, one of these unbound columns is Customer.
I would like to retrieve the value in the Customer column from the dropdown row which matches the underlying OrderID (the Order# from this row is displayed on the grid) and display it in the unbound Customer column, both when the grid is loaded and also when a row is added.
I think this is possible, and supported by ValueListResolved but the documentation on using it is scant and none of the examples I have found are clear enough for me to grasp what I need to do here.
I could create database columns and just store the information directly but that would denormalize the database and doesn't seem necessary.
Can I get some clues, please?
Hello,
I am glad to hear that my sample works for you.
Thank you for using Infragistics Components.
No, you're not missing anything, but I did miss that in the sample - sorry!
That's what I needed - thanks!
You could use the approach which is demonstrate in my sample, iterate through UltraGrid’s rows and populate your unbound column, please pay attention in Load event of the form the following code fragment:
foreach (UltraGridRow row in ultraGrid1.Rows)
{
int key = (int)row.Cells["Order"].Value;
DataRow val = dropDownTable.Rows.Find(key);
row.Cells["Name"].Value = val["Customer"];
}
Please let me know if you have any further questions or if I am missing something
Thanks, Hristo, that's a good starting point.
I can get the functionality to work when a new row is added or an existing value is changed, but I need to find an event which can fire this when the grid is loaded so the unbound columns are populated for existing records.
I know a row must be getting selected because the DisplayMember from the dropdown is displayed in each cell based on the cell's contents which is the ValueMember. I tried InitializeRow but the SelectedRow isn't selected yet when that event fires?
In reading about ValueListResolved it seems there's a way to use an index value (in this case the ValueMember of the dropdown corresponding to the underlying cell value which is available in the InitializeRow event) to get a corresponding value from another column in the list. I think that's the part I need to figure out, because the ValueList is populated in the event.
Knowing how to do that would be a big help, if in fact I'm right about it being possible. I haven't found anything that demonstrates it, though.
In AfterCellUpdate even of UltraGrid, you could cast ValueListResolved property of the UltragridCell object, to UltraCombo and then to get underling data row of the current selected value using SelectedRow.ListObject property. Once you have the underlying data row you could update your unbound column with needed value from this row. I have created a small sample in order to demonstrate you this approach. Please run the sample and let me know if this is what you are looking for.
Please let me know if you have any further questions.