Search results

Field List

The pivot table provides a built-in Field List similar to Microsoft Excel. It allows to add or remove fields and also rearrange them between different axes, including column, row, value, and filter along with sort and filter options dynamically at runtime.

The field list can be displayed in two different formats to interact with pivot table. They are:

  • In-built Field List (Popup): To display the field list icon in pivot table UI to invoke the built-in dialog.
  • Stand-alone Field List (Fixed): To display the field list in a static position within a web page.

In-built Field List (Popup)

To enable the field list in pivot table UI, set the ShowFieldList property in EjsPivotView class to true. A small icon will appear on the top left corner of the pivot table and clicking on this icon, field list dialog will appear.

The field list icon will be displayed at the top right corner of the pivot table, when grouping bar is enabled.

   @using Syncfusion.EJ2.Blazor.PivotView

   <EjsPivotView TValue="ProductDetails" ShowFieldList="true">
        <PivotViewDataSourceSettings DataSource="@dataSource">
           <PivotViewColumns>
               <PivotViewColumn Name="Year"></PivotViewColumn>
               <PivotViewColumn Name="Quarter"></PivotViewColumn>
           </PivotViewColumns>
           <PivotViewRows>
               <PivotViewRow Name="Country"></PivotViewRow>
               <PivotViewRow Name="Products"></PivotViewRow>
           </PivotViewRows>
           <PivotViewValues>
               <PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
               <PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
           </PivotViewValues>
           <PivotViewFormatSettings>
               <PivotViewFormatSetting Name="Amount" Format="C"></PivotViewFormatSetting>
           </PivotViewFormatSettings>
       </PivotViewDataSourceSettings>
   </EjsPivotView>

   @code{
       public List<ProductDetails> dataSource { get; set; }
       protected override void OnInitialized()
       {
          this.dataSource = ProductDetails.GetProductData().ToList();
          //Bind the data source collection here. Refer "Assigning sample data to the pivot table" section in getting started for more details.
       }
   }

output
output

Stand-alone Field List (Fixed)

The field list can be rendered in a static position, anywhere in web page layout, like a separate component. To do so, you need to set RenderMode property to Mode.Fixed in EjsPivotFieldList.

To make field list interact with pivot table, you need to use the UpdateView and Update methods for data source update in both field list and pivot table simultaneously.

        <EjsPivotView TValue="ProductDetails" ID="pivotview"  @ref="pivotView" Height="530">
            <PivotViewEvents TValue="ProductDetails" EnginePopulated="pivotenginepopulated"></PivotViewEvents>
        </EjsPivotView>
        <EjsPivotFieldList TValue="ProductDetails" ID="fieldlist" @ref="fieldList" RenderMode="Mode.Fixed" >
            <PivotFieldListDataSourceSettings DataSource="@data" EnableSorting=true>
                <PivotFieldListColumns>
                    <PivotFieldListColumn Name="Year"></PivotFieldListColumn>
                    <PivotFieldListColumn Name="Quarter"></PivotFieldListColumn>
                </PivotFieldListColumns>
                <PivotFieldListRows>
                    <PivotFieldListRow Name="Country"></PivotFieldListRow>
                    <PivotFieldListRow Name="Products"></PivotFieldListRow>
                </PivotFieldListRows>
                <PivotFieldListValues>
                    <PivotFieldListValue Name="Sold" Caption="Unit Sold"></PivotFieldListValue>
                    <PivotFieldListValue Name="Amount" Caption="Sold Amount"></PivotFieldListValue>
                </PivotFieldListValues>
            </PivotFieldListDataSourceSettings>
            <PivotFieldListEvents TValue="ProductDetails" EnginePopulated="enginepopulated"></PivotFieldListEvents>
        </EjsPivotFieldList>
        <style>
            #fieldlist {
                width: 42%;
                height: 100%;
                float: right;
            }

            #pivotview {
                width: 57%;
                height: 530px;
                float: left;
            }
        </style>
        @code{
            EjsPivotFieldList<ProductDetails> fieldList;
            EjsPivotView<ProductDetails> pivotView;
            public List<ProductDetails> data { get; set; }
            protected override void OnInitialized()
            {
                this.data = ProductDetails.GetProductData();
            }

            public void pivotenginepopulated(EnginePopulatedEventArgs args)
            {
                this.fieldList.Update(this.pivotView);
            }
            public void enginepopulated(EnginePopulatedEventArgs args)
            {
                this.fieldList.UpdateView(this.pivotView);
            }
        }

output

Add or remove fields

Using check box besides each field, end user can select or unselect to add or remove fields respectively from the report at runtime.

output

Remove specific field(s) from displaying

When a data source is bound to the component, fields will be automatically populated inside the Field List. In such case, user can also restrict specific field(s) from displaying. To do so, set the appropriate field name(s) in ExcludeFields property belonging to PivotViewDataSourceSettings class.

   @using Syncfusion.EJ2.Blazor.PivotView

   <EjsPivotView TValue="ProductDetails" ShowFieldList="true">
        <PivotViewDataSourceSettings DataSource="@dataSource" ExcludeFields="@(new string[] { "Products", "Amount" })">
           <PivotViewColumns>
               <PivotViewColumn Name="Year"></PivotViewColumn>
               <PivotViewColumn Name="Quarter"></PivotViewColumn>
           </PivotViewColumns>
           <PivotViewRows>
               <PivotViewRow Name="Country"></PivotViewRow>
               <PivotViewRow Name="Products"></PivotViewRow>
           </PivotViewRows>
           <PivotViewValues>
               <PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
               <PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
           </PivotViewValues>
           <PivotViewFormatSettings>
               <PivotViewFormatSetting Name="Amount" Format="C"></PivotViewFormatSetting>
           </PivotViewFormatSettings>
       </PivotViewDataSourceSettings>
   </EjsPivotView>

   @code{
       public List<ProductDetails> dataSource { get; set; }
       protected override void OnInitialized()
       {
          this.dataSource = ProductDetails.GetProductData().ToList();
          //Bind the data source collection here. Refer "Assigning sample data to the pivot table" section in getting started for more details.
       }
   }

output

Re-arranging fields

In-order to re-arrange, drag any field from the field list and drop it into the column, row, value, or filter axis using the drag-and-drop holder. It helps end user to alter the report at runtime.

output

Filtering members

Using the filter icon besides each field in row, column and filter axes, members can be either included or excluded at runtime. To know more about member filtering, refer here.

output
output
output

Sorting members

Using the sort icon besides each field in row and column axes, members can be arranged either in ascending or descending order at runtime. To know more about member sorting, refer here.

output
output

Calculated fields

The calculated field support allows end user to add a new calculated field based on the available fields from the bound data source using basic arithmetic operators. To enable this support in Field List UI, set the AllowCalculatedField property in EjsPivotView class to true in pivot table. Now a button will be seen automatically inside the field list UI which will invoke the calculated field dialog on click. To know more about calculated field, refer here.

output
output
output

Changing aggregation type of value fields at runtime

End user can perform calculations over a group of values using the aggregation option. The value fields bound to the field list, appears with a dropdown icon, helps to select an appropriate aggregation type at runtime. On selection, the values in the Pivot Table will be changed dynamically. To know more about aggregation, refer here.

output

output
output

Defer layout update

Defer layout update support to update the pivot table only on demand and not during every user action. To enable this support in Field List UI, set the AllowDeferLayoutUpdate property in EjsPivotView class to true in pivot table. Now a check box inside Field List UI will be seen in checked state, allowing pivot table to update only on demand. To know more about defer layout, refer here.

output

Show field list using toolbar

It can also be viewed in toolbar by setting ShowFieldList and ShowToolbar properties in EjsPivotView class to true. Also, include the item ToolbarItems.FieldList within the Toolbar property in EjsPivotView class. When toolbar is enabled, field list icon will be automatically added into the toolbar and the icon won’t appear on top left corner in the pivot table component.

    @using Syncfusion.EJ2.Blazor.PivotView

    <EjsPivotView TValue="ProductDetails" ShowFieldList="true" ShowToolbar="true" Toolbar="@toolbar">
            <PivotViewDataSourceSettings DataSource="@data">
                <PivotViewColumns>
                    <PivotViewColumn Name="Year"></PivotViewColumn>
                    <PivotViewColumn Name="Quarter"></PivotViewColumn>
                </PivotViewColumns>
                <PivotViewRows>
                    <PivotViewRow Name="Country"></PivotViewRow>
                    <PivotViewRow Name="Products"></PivotViewRow>
                </PivotViewRows>
                <PivotViewValues>
                    <PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
                    <PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
                </PivotViewValues>
                <PivotViewFormatSettings>
                    <PivotViewFormatSetting Name="Amount" Format="C"></PivotViewFormatSetting>
                </PivotViewFormatSettings>
            </PivotViewDataSourceSettings>
    </EjsPivotView>

    @code{
        public List<ToolbarItems> toolbar = new List<ToolbarItems> {
            ToolbarItems.FieldList
        };
        public List<ProductDetails> data { get; set; }
        protected override void OnInitialized()
        {
            this.data = ProductDetails.GetProductData().ToList();
            //Bind the data source collection here. Refer "Assigning sample data to the pivot table" section in getting started for more details.
        }
    }

output

Events

EnginePopulated

The EnginePopulated event is available in both Pivot Table and Field List.

  • The event EnginePopulated is triggered in field list whenever the report gets modified. The updated report is passed to the pivot table via UpdateView method written within this event to refresh the same.

  • Likewise, EnginePopulated event is triggered in pivot table whenever the report gets modified. The updated report is passed to the field list via Update method written within this event to refresh the same.

The event EnginePopulated is triggered after engine is populated. It has following parameters - DataSourceSettings, PivotFieldList and PivotValues.

Note: This event is not required for Popup field list since it is a in built one.

        <EjsPivotView TValue="ProductDetails" ID="pivotview"  @ref="pivotView" Height="530">
            <PivotViewEvents TValue="ProductDetails" EnginePopulated="pivotenginepopulated"></PivotViewEvents>
        </EjsPivotView>
        <EjsPivotFieldList TValue="ProductDetails" ID="fieldlist" @ref="fieldList" RenderMode="Mode.Fixed" >
            <PivotFieldListDataSourceSettings DataSource="@data" EnableSorting=true>
                <PivotFieldListColumns>
                    <PivotFieldListColumn Name="Year"></PivotFieldListColumn>
                    <PivotFieldListColumn Name="Quarter"></PivotFieldListColumn>
                </PivotFieldListColumns>
                <PivotFieldListRows>
                    <PivotFieldListRow Name="Country"></PivotFieldListRow>
                    <PivotFieldListRow Name="Products"></PivotFieldListRow>
                </PivotFieldListRows>
                <PivotFieldListValues>
                    <PivotFieldListValue Name="Sold" Caption="Unit Sold"></PivotFieldListValue>
                    <PivotFieldListValue Name="Amount" Caption="Sold Amount"></PivotFieldListValue>
                </PivotFieldListValues>
            </PivotFieldListDataSourceSettings>
            <PivotFieldListEvents TValue="ProductDetails" EnginePopulated="enginepopulated"></PivotFieldListEvents>
        </EjsPivotFieldList>
        <style>
            #fieldlist {
                width: 42%;
                height: 100%;
                float: right;
            }

            #pivotview {
                width: 57%;
                height: 530px;
                float: left;
            }
        </style>
        @code{
            EjsPivotFieldList<ProductDetails> fieldList;
            EjsPivotView<ProductDetails> pivotView;
            public List<ProductDetails> data { get; set; }
            protected override void OnInitialized()
            {
                this.data = ProductDetails.GetProductData();
            }

            public void pivotenginepopulated(EnginePopulatedEventArgs args)
            {
                this.fieldList.Update(this.pivotView);
            }
            public void enginepopulated(EnginePopulatedEventArgs args)
            {
                this.fieldList.UpdateView(this.pivotView);
            }
        }

FieldListRefreshed

The event FieldListRefreshed is triggered whenever there is any change done in the field list UI. It has following parameter - DataSourceSettings and PivotValues. It allows user to identify each field list update. This event is applicable only for static field list.

    <EjsPivotView TValue="ProductDetails" ID="pivotview"  @ref="pivotView" Height="530">
        <PivotViewEvents TValue="ProductDetails" EnginePopulated="pivotenginepopulated"></PivotViewEvents>
    </EjsPivotView>
    <EjsPivotFieldList TValue="ProductDetails" ID="fieldlist" @ref="fieldList" RenderMode="Mode.Fixed" >
        <PivotFieldListDataSourceSettings DataSource="@data" EnableSorting=true>
            <PivotFieldListColumns>
                <PivotFieldListColumn Name="Year"></PivotFieldListColumn>
                <PivotFieldListColumn Name="Quarter"></PivotFieldListColumn>
            </PivotFieldListColumns>
            <PivotFieldListRows>
                <PivotFieldListRow Name="Country"></PivotFieldListRow>
                <PivotFieldListRow Name="Products"></PivotFieldListRow>
            </PivotFieldListRows>
            <PivotFieldListValues>
                <PivotFieldListValue Name="Sold" Caption="Unit Sold"></PivotFieldListValue>
                <PivotFieldListValue Name="Amount" Caption="Sold Amount"></PivotFieldListValue>
            </PivotFieldListValues>
        </PivotFieldListDataSourceSettings>
        <PivotFieldListEvents TValue="ProductDetails" EnginePopulated="enginepopulated"></PivotFieldListEvents>
    </EjsPivotFieldList>
    <style>
        #fieldlist {
            width: 42%;
            height: 100%;
            float: right;
        }

        #pivotview {
            width: 57%;
            height: 530px;
            float: left;
        }
    </style>
    @code{
        EjsPivotFieldList<ProductDetails> fieldList;
        EjsPivotView<ProductDetails> pivotView;
        public List<ProductDetails> data { get; set; }
        protected override void OnInitialized()
        {
            this.data = ProductDetails.GetProductData();
        }

        public void pivotenginepopulated(EnginePopulatedEventArgs args)
        {
            this.fieldList.Update(this.pivotView);
        }
        public void enginepopulated(EnginePopulatedEventArgs args)
        {
            this.fieldList.UpdateView(this.pivotView);
        }
        private void fieldlistrefresh(FieldListRefreshedEventArgs args)
        {
            //args.DataSourceSettings -> user can view updated datasource settings
        }
    }

FieldDropped

The event FieldDropped fires whenever a field is dropped in an axis. It has following parameters - DroppedAxis, DroppedField and DataSourceSettings. In this illustration, we have modified the DroppedField caption through this event at runtime.

    @using Syncfusion.EJ2.Blazor.PivotView

    <EjsPivotView TValue="ProductDetails" ShowFieldList="true">
            <PivotViewDataSourceSettings DataSource="@data">
                <PivotViewColumns>
                    <PivotViewColumn Name="Year"></PivotViewColumn>
                    <PivotViewColumn Name="Quarter"></PivotViewColumn>
                </PivotViewColumns>
                <PivotViewRows>
                    <PivotViewRow Name="Country"></PivotViewRow>
                    <PivotViewRow Name="Products"></PivotViewRow>
                </PivotViewRows>
                <PivotViewValues>
                    <PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
                    <PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
                </PivotViewValues>
                <PivotViewFormatSettings>
                    <PivotViewFormatSetting Name="Amount" Format="C"></PivotViewFormatSetting>
                </PivotViewFormatSettings>
            </PivotViewDataSourceSettings>
            <PivotViewEvents TValue="ProductDetails" FieldDropped="fielddropped"></PivotViewEvents>
    </EjsPivotView>

    @code{
        public List<ProductDetails> data { get; set; }
        protected override void OnInitialized()
        {
            this.data = ProductDetails.GetProductData().ToList();
            //Bind the data source collection here. Refer "Assigning sample data to the pivot table" section in getting started for more details.
        }
        public void fielddropped(FieldDroppedEventArgs args)
        {
            args.DroppedField.Caption = args.DroppedField.Name + " --> " + args.DroppedAxis;
        }
    }

output