Product Update: Ext JS 8.0 is Coming Soon! Learn More

Configuration and Customization Options in Ext JS Pivot Grid

July 14, 2020 2306 Views

Get a summary of this article:

Show

Pivot Grids are powerful tools to represent data and extract valuable insights from it. In the last post we looked at the 5 powerful features of the Ext JS Pivot Grid. In this blog post we demonstrate Pivot Grid Configuration and Customization examples you can directly use into your application.

Pivot Grid Configuration

pivot_grid_configurator
How to:

 
plugins: {
	pivotconfigurator: {
    	id: 'configurator',
    	// It is possible to configure a list of fields that can be used to
    	// configure the pivot grid
    	// If no fields list is supplied then all fields from the Store model
    	// are fetched automatically
    	fields: [{
            dataIndex: 'quantity',
            header: 'Qty',
            // You can even provide a default aggregator function to be used
            // when this field is dropped
            // on the agg dimensions
            aggregator: 'min',
            formatter: 'number("0")',
 
            settings: {
                // Define here in which areas this field could be used
                allowed: ['aggregate'],
                // Set a custom style for this field to inform the user that
                // it can be dragged only to "Values"
                style: {
                    fontWeight: 'bold'
                },
                // Define here custom formatters that ca be used on this dimension
                formatters: {
                    '0': 'number("0")',
                    '0%': 'number("0%")'
                }
            }
    	}, {
            dataIndex: 'value',
            header: 'Value',
 
            settings: {
                // Define here in which areas this field could be used
                allowed: 'aggregate',
                // Define here what aggregator functions can be used when this
                // field is used as an aggregate dimension
                aggregators: ['sum', 'avg', 'count'],
                // Set a custom style for this field to inform the user that it
                // can be dragged only to "Values"
                style: {
                    fontWeight: 'bold'
                },
                // Define here custom renderers that can be used on this dimension
                renderers: {
                    'Colored 0,000.00': 'coloredRenderer'
                },
                // Define here custom formatters that ca be used on this dimension
                formatters: {
                    '0': 'number("0")',
                    '0.00': 'number("0.00")',
                    '0,000.00': 'number("0,000.00")',
                    '0%': 'number("0%")',
                    '0.00%': 'number("0.00%")'
                }
            }
    	}, {
            dataIndex: 'company',
            header: 'Company',
 
            settings: {
                // Define here what aggregator functions can be used when this
                // field is used as an aggregate dimension
                aggregators: ['count']
            }
    	}, {
            dataIndex: 'country',
            header: 'Country',
 
            settings: {
                // Define here what aggregator functions can be used when this
                // field is used as an aggregate dimension
                aggregators: ['count']
            }
    	}, {
            dataIndex: 'person',
            header: 'Person',
 
            settings: {
                // Define here what aggregator functions can be used when this
                // field is used as an aggregate dimension
                aggregators: 'count'
            }
    	}, {
            dataIndex: 'year',
            header: 'Year',
 
            settings: {
                // Define here the areas in which this field is fixed and cannot
                // be moved from
                fixed: ['topAxis']
            }
    	}, {
            dataIndex: 'month',
            header: 'Month',
            labelRenderer: 'monthLabelRenderer',
 
            settings: {
                // Define here what aggregator functions can be used when this
                // field is used as an aggregate dimension
                aggregators: ['count'],
                // Define here in which areas this field could be used
                allowed: ['leftAxis', 'topAxis']
            }
    	}]
	}
}

Sencha Fiddle:

Pivot Grid Customizations

Ext JS Pivot Grid provides many customization options.
How to :

 
	matrix: {
        //Define "compact" layout
        viewLayoutType: 'compact',
        compactViewColumnWidth: 250,
        textRowLabels: 'Row labels',
        //First column is a grand total
        colGrandTotalsPosition: 'first',
        store: {
            type: 'sales'
        },
        aggregate: [{
            dataIndex: 'value',
            header: 'Total',
            aggregator: 'sum',
            renderer: function (value, meta, record) {
                //Add CSS background
                if (value > 40000) {
                    meta.style = "background-color: green;";
                }
 
               if (value != null && value < 10000) {
                    meta.style = "background-color: red;";
                }
 
                return Ext.util.Format.number(value, '0,000.00');
 
            }
        }],
        leftAxis: [{
            dataIndex: 'person',
            header: 'Person'
        }, {
            dataIndex: 'year',
            header: 'Year'
        }],
        topAxis: [{
            dataIndex: 'continent',
            header: 'Continent'
        }, {
            dataIndex: 'country',
            header: 'Country'
        }]
    }

Sencha Fiddle:

More Plugins

More pivot grid plugins such as Cell Editing and Exporter are also available. View detailed documentation.

Build Your Pivot Grid with Ext JS 7.2

The free 30-day trial of Ext JS 7.2 provides full access to the product features. Get started today and see how you can build a powerful pivot grid to make insights from data more apparent.

Recommended Articles

Why JavaScript UI Components Matter More in Complex Frontend Architecture

What This Article Covers Why UI components matter – In complex frontend architecture, reusable JavaScript UI components help manage scale, improve performance, and ensure consistency…

Custom vs Prebuilt JavaScript UI Components – Which Is Better for Enterprise

What This Article Covers Build vs. Buy decision – Whether to build custom JavaScript UI components, use open-source libraries, adopt commercial solutions, or follow a…

How a JavaScript UI Framework Reduces Frontend Complexity

Frontend development has become dramatically more sophisticated over the last decade. What once involved a few scripts and styled pages has evolved into the engineering…

10 Common UI Pain Points in Large-Scale JavaScript Applications

At a small scale, many frontend decisions appear harmless. A team may: create a custom component quickly skip accessibility for one release add a one-off…

Common Responsive Design Challenges in Enterprise Web Applications

Modern businesses run on software that must work everywhere – on a desktop monitor in a corporate office, on a tablet carried across a warehouse…

Why Enterprise UI Development Gets Complicated Faster Than Teams Expect

Enterprise UI development refers to designing and building user interfaces for business-critical software used by organizations, departments, regulated industries, and large operational teams. These applications…

View More