Hi,
I have the following problem:
This code does not change the properties of the dimensions:
CubeMetadata cubeMetadata = new CubeMetadata();cubeMetadata.DataTypeFullName = "Cubo";cubeMetadata.DimensionSettings.Add(new DimensionMetadata(){SourcePropertyName = "CNPJ",DisplayName = "CNPJ",DimensionType = DimensionType.Dimension});
To be more specific,The information comes from a service which brings me to the data.
Where that service return a list ObservableCollection That loads the ItemSource(FlatDataSource).
My problem is when I want to change the names of the dimensions
but I can not change the DisplayName property.
I have the following code:
public void dados_CarregarDadosCompleted(Object sender, wsUPDados.ConsultaFaturasUPCompletedEventArgs e) {
FlatDataSource DataSource = new FlatDataSource { ItemsSource = e.result;
}; CubeMetadata cubeMetadata = new CubeMetadata(); cubeMetadata.DataTypeFullName = "Cubo"; cubeMetadata.DimensionSettings.Add(new DimensionMetadata() { SourcePropertyName = "CNPJ", DisplayName = "CNPJ", DimensionType = DimensionType.Dimension }); cubeMetadata.DimensionSettings.Add(new DimensionMetadata() { SourcePropertyName = "Codigo_Cliente", DisplayName = "Codigo Cliente", DimensionType = DimensionType.Dimension }); cubeMetadata.DimensionSettings.Add(new DimensionMetadata() { SourcePropertyName = "Codigo_Conta", DisplayName = "Codigo Conta", DimensionType = DimensionType.Dimension }); cubeMetadata.DimensionSettings.Add(new DimensionMetadata() { SourcePropertyName = "Codigo_Fatura", DisplayName = "XXX Holding", DimensionType = DimensionType.Dimension });
DataSource.CubesSettings.Add(cubeMetadata);
//dataSelector.DataSource = DataSource; /////
HierarchyDescriptor dateTimeDescriptor = new HierarchyDescriptor { AppliesToPropertiesOfType = typeof(DateTime) }; dateTimeDescriptor.AddLevel<DateTime>(dt => dt.Year, "Ano"); dateTimeDescriptor.AddLevel<DateTime>(dt => dt.MonthShort(), "Mês"); DataSource.HierarchyDescriptors.Add(dateTimeDescriptor);
this.pivotGrid.DataSource = DataSource; this.dataSelector.DataSource = DataSource;
DataSource.ParentInFrontForColumns = true;
DataSource.DimensionsGenerationMode = DimensionsGenerationMode.Mixed;
}
Thank you,
This is the complete code:
In the Xaml :
I Have this..
<UserControl x:Class="PMESP.Cofin.Silverlight.PivotGridGeral" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" xmlns:framework="clr-namespace:Infragistics.Samples.Framework;assembly=Infragistics.Samples.Framework" d:DesignHeight="600" d:DesignWidth="790" xmlns:ig="http://schemas.infragistics.com/xaml" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:igOlap="http://schemas.infragistics.com/olap" xmlns:local="clr-namespace:IGPivotGrid.Samples.Controls" > <Grid x:Name="LayoutRoot" Background="White" Margin="10,10,0,0"> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <ig:XamPivotGrid x:Name="pivotGrid" /> <ig:Expander Grid.Column="1"> <ig:XamPivotDataSelector x:Name="dataSelector" /> </ig:Expander>
<sdk:Label HorizontalAlignment="Left" Height="19" Margin="10,7,0,0" VerticalAlignment="Top" Width="65" Content="Data Inicial"/> <ig:XamDateTimeInput x:Name="DataInicial" HorizontalAlignment="Left" Margin="82,5,0,0" VerticalAlignment="Top" Width="95"/> <sdk:Label HorizontalAlignment="Left" Height="19" Margin="187,7,0,0" VerticalAlignment="Top" Width="60" Content="Data Final"/> <ig:XamDateTimeInput x:Name="DataFinal" HorizontalAlignment="Left" Margin="254,5,0,0" VerticalAlignment="Top" Width="95"/> <Button Content="Atualizar" HorizontalAlignment="Left" Margin="357,5,0,0" VerticalAlignment="Top" Width="66" Click="Click_Atualizar"/> <Button Content="Salvar" HorizontalAlignment="Left" Margin="428,5,0,0" VerticalAlignment="Top" Width="48" Click="Click_Salvar" ToolTipService.ToolTip="Salva customização da consulta"/> <Button Content="Excel" HorizontalAlignment="Left" Margin="500,5,0,0" VerticalAlignment="Top" Width="48" Click="Click_Excel" ToolTipService.ToolTip="Exportar para planilha excel"/> </Grid></UserControl>
In the Xaml.cs :
public PivotGridGeral() { InitializeComponent(); DateTime data = new DateTime(DateTime.Now.Year, 1, 1); DataInicial.Value = data; DataFinal.Value = DateTime.Now; //this.pivotGrid.DataSource.PropertyChanged += DataSource_PropertyChanged; } public void CarregarDadosWS(DateTime dataInicial, DateTime dataFinal) { wsUPDados.UPdadosClient dados = new wsUPDados.UPdadosClient("BasicHttpBinding_IUPdados"); dados.ConsultaFaturasUPCompleted += new EventHandler<wsUPDados.ConsultaFaturasUPCompletedEventArgs>(dados_CarregarDadosCompleted); dados.ConsultaFaturasUPAsync(dataInicial, dataFinal); } public void dados_CarregarDadosCompleted(Object sender, wsUPDados.ConsultaFaturasUPCompletedEventArgs e) { HtmlDocument document = HtmlPage.Document; HtmlElement elemUge = document.GetElementById("MainContent_hdCodigoUge"); CodUge = elemUge.GetAttribute("value").ToString().Trim(); HtmlElement elemCPF = document.GetElementById("MainContent_hdCPF"); CPF = elemCPF.GetAttribute("value").ToString().Trim(); FlatDataSource DataSource = new FlatDataSource { ItemsSource = e.Result
}; CubeMetadata cubeMetadata = new CubeMetadata(); cubeMetadata.DataTypeFullName = "Cubo"; cubeMetadata.DimensionSettings.Add(new DimensionMetadata() { SourcePropertyName = "CNPJ", DisplayName = "CNPJ", DimensionType = DimensionType.Dimension }); cubeMetadata.DimensionSettings.Add(new DimensionMetadata() { SourcePropertyName = "Codigo_Cliente", DisplayName = "Codigo Cliente", DimensionType = DimensionType.Dimension }); cubeMetadata.DimensionSettings.Add(new DimensionMetadata() { SourcePropertyName = "Codigo_Conta", DisplayName = "Codigo Conta", DimensionType = DimensionType.Dimension }); cubeMetadata.DimensionSettings.Add(new DimensionMetadata() { SourcePropertyName = "Codigo_Fatura", DisplayName = "Codigo Factura", DimensionType = DimensionType.Dimension });
// CarregarCustomizacao(); }
private void Click_Atualizar(object sender, RoutedEventArgs e) { DateTime dataInicial = (DateTime)DataInicial.Value; DateTime dataFinal = (DateTime)DataFinal.Value; CarregarDadosWS(dataInicial, dataFinal); }
And this code is the service that returns the list to be loaded into the ItemSource:
public ObservableCollection<BusinessEntities.SL_UP> ConsultaFaturasUP(DateTime DataInicial, DateTime DataFinal) { BusinessEntities.SL_UP faturaEntities = new BusinessEntities.SL_UP(); ObservableCollection<BusinessEntities.SL_UP> lista = new ObservableCollection<BusinessEntities.SL_UP>(); Business.SL_UP faturas = new Business.SL_UP(); lista=faturas.ConsultaFaturasUP(DataInicial, DataFinal); try { return lista; } catch (Exception excecao) { throw new BusinessEntities.Excecao(excecao, id: 1); } }
Hopefully this more clear and you can have your help
thank you,
Hello Jorge,
I doubt your data type full name is "Cubo"
cubeMetadata.DataTypeFullName = "Cubo";
Could you please try with the full type name?
Regards,Plamen.
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.