Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
62
xamPivotGrid Cell Display Format Issue
posted

Hi,

Our company(reportdev) wants to launch an OLAP analysis and reporting tool. Everything is going fine but we are now in need of a smart, intelligent and on the fly analytical powerfull pivot-grid that has capabilities of the followings to deliver our customer's needs satisfactorily:-

# Run-time pivoting

# Dril-down

# Export to excel, pdf etc.

# Formatted cell values incl. currency symbols, rounding upto n decimal places etc.

# Charting capabilities and so many more func.

We've tested lots of grids but Infragistics xamPivotGrid seems to be an ideal amongst them. I've downloaded and install the trial version of the grid(NetAdvantage_SilverlightDVWithSamplesAndHelp_20103.exe) and developing app using adomd connection followed  by the sample CustomDataProvider .

Everything goes fine but,

Our customers want an option whether they would like to view custom-formatted cell data($#,##0.00;($#,##0.00)) by a check box click.

Also, there is a problem saying 'Message: Element is already the child of another element.' while exporting a large number of data rows(for more than 3 thousands) to excel but it works great for a small amount of rows.

Is it possible to fix them up, how?

Thnx,

- Sb.

Parents
  • 7922
    posted

    Hi,

     

    The way to do custom formatted value is as follow:

    1.       Create new cell style as resource

     

    <Style x:Key="ScaledCell" TargetType="ig:PivotCellControl">

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="ig:PivotCellControl">

                    <Grid>

                        <Border x:Name="Root" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"

                            Background="{TemplateBinding Background}" />

                        <Grid>

                            <Grid.ColumnDefinitions>

                                <ColumnDefinition Width="*" />

                            </Grid.ColumnDefinitions>

                            <TextBlock Name="cellPresenter" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Cell.Data, Converter={StaticResource CellValueFormat}}"

                                    Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5" />

                        </Grid>

                    </Grid>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

     

    2.       Add converter class to your project. In convert method apply your custom formatting logic.

     

    using System.Windows.Data;

     

    using Infragistics.Olap.Data;

     

    public class FormatValueConverter : IValueConverter

    {

        #region IValueConverter Members

     

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

        {

            ICell cell = value as ICell;

            if (cell != null)

            {

                return string.Format("$ ## {0}", cell.Value);

            }

     

            return "";

        }

     

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

        {

            return "";

        }

     

        #endregion

    }

     

    3.       Apply the new style to pivot cell

     

    <ig:XamPivotGrid Grid.Column="0" Name="pivotGrid" DataSource="{StaticResource pivotGridDataSource}" CellStyle="{StaticResource ScaledCell}"/>

     

     

    This should work for your case.

     

    About excel export, which code do you use for exporting. Could you attach little sample for this issue.

     

    Regards

    Todor

Reply Children
No Data