JS Days 2025 is now live – Join 5,000+ devs for the premier virtual JavaScript event. Register Now

Configuration and Customization Options in Ext JS Pivot Grid

July 14, 2020 1556 Views
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

Guide to Estimating ROI When Switching From DIY Libraries to Full Software Development Platforms Like Ext JS

Teams started with Do It Yourself, or DIY, JavaScript tools like jQuery and Bootstrap. But those fall apart as projects scale. Scattered code, user interface…

Top Frameworks Developers Are Using for Custom Software Development in 2025

We’re seeing it more every year; teams aren’t settling for plug-and-play tools anymore. In healthcare, finance, logistics, and other data-heavy industries, there’s a clear shift.…

Meet Sencha AI Coding Companion: Your AI-Powered Assistant for Faster Ext JS Development

Building modern web applications should be exciting. But too often, developers find themselves buried in documentation, endlessly Googling framework quirks, or stuck solving the same…

Ext JS 7.9 & Rapid Ext JS V1.1 Have Arrived

The Sencha team is excited to announce the latest Ext JS version 7.9 and Rapid Ext JS 1.1 release – designed to accelerate development, enhance…

Top 10 JS Grid Customization Tips for a Better UI Experience

Grids are pretty much everywhere in web apps. Working with financial sheets, product details, or users? Then you’ve probably used a JavaScript grid. It makes…

Why Ext JS Framework is the Go-To Framework for Building Scalable and Data-Intensive Web Apps

Web apps are much more advanced now. They deal with large amounts of data and need to stay fast, even with many users. If you’re…

View More

Trusted by Top Developers: Learn how to enhance your development journey — for free

Get the latest newsletter keeping thousands of developers in the loop.

Loved by developers at