How do I change the GroupByAreaFieldLabel to display the name instead of the value when the field is based on a column that uses a ComboBox as an editor style?
So for instance, when I group by "CustomerType" , the GroupByAreaFieldLabel shows the ID (i.e. 7) of the type rather than the string.
Hello,
I have tested this and it is working correctly. Please provide more information on your scenario. What is the ItemsSource of the ComboBox or you use a ComboBoxItemsProvider. Have you set DisplatMemberPath and ValuePath?
Regards,
Alex.
Attached is a sample application.
When you group by Customer Type (the ComboBox) it shows the ID instead of the text.
I've modified your code so please take a look at the sample project and tell me if this is what you need or is someting else.
Best Regards
Vlad
Thank you for the reply but it is the same problem that I have.
I have two differnet data sources, one for the customer and one for the customer type and the customer type is the combo box.
For the combo box, I have the DisplayMemberPath set to the Name (the string description of the CustomerType) and the ValueMember set to the ID (the foreign key in the Customers class). When the grid is displayed the data is shown exactly the way I want, it shows the customer name and the string description of the type (gold, standard...etc) However when you group by customer type, the group row shows the ID rather than the string description. I've attached an image of what I'm talking about..
Thanks again!
One way to do this is setting a custom description to the GroupByRecord. For that purpose you can handle the InitializeRecord event of the XamDataGrid like that :
private void dgGrid_InitializeRecord( object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e)
{
GroupByRecord gbr = e.Record as GroupByRecord;
if (gbr != null)
if (gbr.Value.ToString() == "1")
gbr.Description = "Standard "+
"("+
gbr.ViewableChildRecords.Count.ToString()+
")" ;
}
else if (gbr.Value.ToString() == "2")
gbr.Description = "Gold "+
")";
else
gbr.Description="none";
Hope this helps
If you are using a dynamically populated Combo Editor or if you have multiple Combo Editors in your XamDataGrid, you might have to use more generic approach like:
Enum.GetName(typeof(WpfApplication1.CustomerType.CustomerTypes),0)
To get the Name from the Value of the Enum:
gbr.Description = Enum.GetName(typeof(WpfApplication1.CustomerType.CustomerTypes), 1) +
"(" +
gbr.ViewableChildRecords.Count.ToString() +
Thanks, I understand what you're doing now. In the real application my combo box is dynamic but I can definitly code around that to make it work. The InitializeRecord event and GroupByRecord is exactly what I neeed.
Thanks again!!