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
Hi again,
Please attach a descriptive screenshot of a XamPivotGrid and mark the PivotGridCells you feel are in one column.
Looking forward to hearing from you.
Hi Peter,
I am sorry I was not clear in my question. I need to format PivotHeaderCells and not PivotCells.
Unfortunately CellControlAttached does not solve my problem as it only applied to PivotCells and not PivotHeaderCells.
I would be nice to have CellControlAttached event apply to both PivotCells and PivotHeaderCells. Or atleast have a similar event for PivotHeaderCells.
Hi Petar,
Thanks for your reply.
I learnt about and used the CellControlAttached event myself yesterday for another problem. As you suggested, yes I think it is applicable to this as well. Am going to try it out and let you know.
Hello Sangeetha,
Excuse me for the confusion I have spent some more time looking for a solution on your issue and think this I time I nailed it. I managed to use the CellControlAttached event to filter through the data cells and apply the formatting style from my previous sample only to those that meet a certain criteria. In the sample project I have created for you initially there are two measures loaded in the XamPivotGrid and I check and apply my Style only to the ones that come from the “Cost” measure. Also there is a ComboBox in the top right corner which SelectedItem sets a format for the “Cost” measure data cells dynamically thanks to a MultiBinding I used in the “CellStyle” style.
Please look through your sample project (PivotGrid_formatting_data.zip) and let me know if you require any further clarification on this custom approach.
My problem is, I set the Style in LayoutUpdated (as I need to set it only for a specific column), so when the Converter is executed, LayoutUpdated is fired again - so it goes into an infinite loop.
If I can find a better event to set the style in, my problem would be resolved.