Hi,
I am trying to format data dynamically, by allowing user to choose date format from context menu. The following is the event handler I use. When I debug I see that FlatDataSource is updated, but for some reason the grid is not updated. Could you please tell me what I am doing wrong. Or is this a bug?? Refreshing the grid doesn't seem to help.
private void QuickDates_Click(object sender, RoutedEventArgs e) { if (pivotGrid.DataSource != null) { MenuItem mi = sender as MenuItem; string dateFormat = mi.Header as string; FlatDataSource flatDataSource = pivotGrid.DataSource as FlatDataSource; int index = 0; foreach (DimensionMetadata metaData in flatDataSource.CubesSettings[0].DimensionSettings) { if (metaData.SourcePropertyName.Equals("End Date")) { flatDataSource.CubesSettings[0].DimensionSettings[index++].DisplayFormat = dateFormat; //metaData.DisplayFormat = dateFormat; break; } index++; } } }
Thanks
Sangeetha
Hello,
Currently such functionality is not supported and these settings are used only when the control is initialized.
Regards.Plamen.
Thank You Plamen.
Is there an alternative to this?
Hi Petar,
In the image below, I want to format the PivotHeaderCells in PivotHeaderColumn EndDate dynamically.
Hi Sangeetha,
Here is a new sample approach (PivotGrid_formatting_HeaderCells.zip). Please look into it and let me know if this is what you were looking for.
Looking forward to hearing from you.
Thank You for your great solution. I used it to figure out what was wrong with mine - it works perfectly now. I had been setting the style to the PivotHeadercellControl instead of the PivotHeaderCell itself. Setting it to the PivotHeaderCell does not fire LayoutUpdated when the format is updated.
There is one other small thing that needs to be fixed. Right now I hardcode the format in the converter. I would like to set this format through the Converter's parameter. In other words I want to see the format coming through in the following function. How can I do this?
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ }
You can see how I have managed to get the format to come from the ComboBox in the top right corner through the binding in the sample I last sent. I used a MultiValueConverter in order to have a non-static format value. Now since the binging comes from it and from the cell values if there is a change in any of those the values are reconfigured.
Please let me know if you require any further clarification on the matter.
Replacing IValueConverter with IMultiValueConverter did the trick. It works perfectly now.