Blazor Pivot Grid Overview

    Ignite UI for Blazor Pivot Grids are used for summing up and representing voluminous multidimensional data in a cross-tabular format. The data summery can be easily and quickly sorted, grouped, or filtered. Such data can include sums, averages, and other statistics. End-users are enabled to modify the pivot table layout through drag-and-drop operations, according to their needs.

    What is Blazor Pivot Grid?

    The Blazor PivotGrid presents data in a pivot table and helps performing complex analysis on the supplied data set. This sophisticated Pivot Grid control is used for organizing, summarizing, and filtering large volumes of data which is later displayed in a cross-table format. Key features of an Blazor Pivot Grid are row dimensions, column dimensions, aggregations, and filters.

    The IgbPivotGrid gives the ability to users to configure and display their data in a multi-dimensional pivot table structure. The rows and columns represent distinct data groups, and the data cell values represent aggregations. This allows complex data analysis based on a simple flat data set. The IgbPivotGrid is a feature-rich pivot table that provides easy configuration of the different dimensions and values as well as additional data operations on them like filtering and sorting.

    Blazor Pivot Grid Example

    The following is an Blazor Pivot Grid example in combination with the Blazor Pivot Data Selector Component. This way you can have more flexible runtime configuration options.

    Getting Started With Blazor Pivot Grid

    The Blazor PivotGrid can be configured via the PivotConfiguration property.

    <IgbPivotGrid PivotConfiguration="PivotConfiguration" Data="PivotData">
    </IgbPivotGrid>
    

    It is defined by three main dimensions: rows, columns and values. The rows and columns define the grouped structure that is displayed in the rows and columns of the grid. The values define the aggregation fields and the aggregation that will be used to calculate and display the related values of the groups.

    A filter can also be defined via the filters configuration property. It can be used for fields that you do not want to add as a dimension or a value but would like to filter their related member values via the UI.

    Dimensions Configuration

    Each basic dimension configuration requires a MemberName that matches a field from the provided data.

    @code {
        IgbPivotDateDimension dateDim = new IgbPivotDateDimension();
        dateDim.BaseDimension = new IgbPivotDimension()
            {
                MemberName = "Date",
                Enabled = true
            };
        _config.Rows.Add(dateDim);
    }
    

    It also allows for further customization via the second option parameter in order to enable or disable a particular part of the hierarchy, for example:

    @code {
        IgbPivotDateDimension dateDim = new IgbPivotDateDimension();
        dateDim.BaseDimension = new IgbPivotDimension()
            {
                MemberName = "Date",
                Enabled = true
            };
        dateDim.Options = new IgbPivotDateDimensionOptions()
            {
                Years = true,
                Months = true,
                FullDate = true,
                Quarters = true
            };
        _config.Rows.Add(dateDim);
    }
    

    Values Configuration

    A value configuration requires a member that matches a field from the provided data, or it can define a custom aggregator function for more complex custom scenarios. Out of the box, there are 4 predefined aggregations that can be used depending on the data type of the data field:

    • PivotNumericAggregate - for numeric fields. Contains the following aggregation functions: SUM, AVG, MIN, MAX, COUNT.
    • PivotDateAggregate - for date fields. Contains the following aggregation functions: LATEST, EARLIEST, COUNT.
    • PivotTimeAggregate - for time fields. Contains the following aggregation functions: LATEST, EARLIEST, COUNT.
    • PivotAggregate - for any other data types. This is the base aggregation. Contains the following aggregation functions: COUNT.

    The current aggregation function can be changed at runtime using the value chip's drop-down. By default, it displays a list of available aggregations based on the field's data type. A custom list of aggregations can also be set via the AggregateList property, for example:

    @code {
        IgbPivotConfiguration pivotConfiguration1 = new IgbPivotConfiguration();
        IgbPivotValue pivotValue = new IgbPivotValue()
            {
                Member = "Sales",
                Name = "pivotValue1",
                DisplayName = "Amount of Sales",
                Enabled = true,
                Aggregate = new IgbPivotAggregator() { Key = "sum", AggregatorName = PivotAggregationType.SUM, Label = "Sum of Sales" }
            };
        pivotValue.AggregateList.Add(new IgbPivotAggregator() { Key = "sum", AggregatorName = PivotAggregationType.SUM, Label = "Sum of Sales" });
        pivotValue.AggregateList.Add(new IgbPivotAggregator() { Key = "min", AggregatorName = PivotAggregationType.MIN, Label = "Minimum of Sales" });
        pivotValue.AggregateList.Add(new IgbPivotAggregator() { Key = "max", AggregatorName = PivotAggregationType.MAX, Label = "Maximum of Sales" });
        pivotConfiguration1.Values.Add(pivotValue);
    

    The pivot value also provides a DisplayName property. It can be used to display a custom name for this value in the column header.

    Enable Property

    PivotConfiguration is the interface that describes the current state of the IgbPivotGrid component. With it the developer can declare fields of the data as rows, columns, filters or values. The configuration allows enabling or disabling each of these elements separately. Only enabled elements are included in the current state of the Pivot Grid. The IgbPivotDataSelector component utilizes the same configuration and shows a list of all elements - enabled and disabled. For each of them there is a checkbox in the appropriate state. End-users can easily tweak the pivot state by toggling the different elements using these checkboxes. The Enable property controls if a given IgbPivotDimension or IgbPivotValue is active and takes part in the pivot view rendered by the Pivot Grid.

    Full Configuration Code

    Let's take a look at a basic pivot configuration:

        IgbPivotConfiguration pivotConfiguration = new IgbPivotConfiguration();
        pivotConfiguration.Rows.Add(new IgbPivotDimension()
            {
                MemberName = "SellerName",
                Enabled = true,
                Name = "pivotDimension1"
            });
        pivotConfiguration.Columns.Add(new IgbPivotDimension()
            {
                MemberName = "ProductName",
                Enabled = true,
                Name = "pivotDimension2"
            });
        pivotConfiguration.Columns.Add(new IgbPivotDimension()
            {
                MemberName = "SellerCity",
                Enabled = true,
                Name = "pivotDimension2"
            });
        pivotConfiguration.Values.Add(new IgbPivotValue()
            {
                Member = "AmountofSale",
                Name = "pivotValue1",
                Enabled = true,
                Aggregate = new IgbPivotAggregator() { Key = "SUM", AggregatorName = PivotAggregationType.SUM, Label = "Sum" }
            });
    }
    

    This configuration defines 1 row, 1 column and 1 aggregation that sums the values of each dimension groups. The members match fields available in the provided data source:

    public PivotDataFlat()
    {
        this.Add(new PivotDataFlatItem()
        {
            ProductName = @"Clothing",
                ProductUnitPrice = 12.8,
                SellerName = @"Stanley Brooker",
                SellerCity = @"Seattle",
                Date = @"2007-01-01T00:00:00",
                Value = 94.4,
                NumberOfUnits = 282
        });
    

    Full Configuration Example

    Using above code will result in the following example which groups the Date unique columns, Product Name and Seller City in unique rows and displays the related aggregations for the amount of sale in the related cells:

    Known Issues and Limitations

    Limitation Description
    Setting columns declaratively is not supported. The Pivot grid generates its columns based on the Columns configuration, so setting them declaratively, like in the base grid, is not supported. Such columns are disregarded.
    Setting duplicate MemberName or Member property values for dimensions/values. These properties should be unique for each dimension/value. Duplication may result in loss of data from the final result.
    Row Selection is only supported in Single mode. Multiple selection is currently not supported.

    API References

    Additional Resources

    Our community is active and always welcoming to new ideas.