1
votes

In the following example I have a grid with a widgetcolumn with the percentage of the sum of the total value of another column:

FIDDLE: https://fiddle.sencha.com/#view/editor&fiddle/1uh5

However, I could not print the widgetcolumn.

I needed to get exactly the same precentage values in the precent column.

Any ideas how to do this without a dataindex config and client side?

1

1 Answers

1
votes

Can you explain why you don't want to use dataIndex config?

I've found workaround, but it's an ugly solution. I do not recommend to use it in production environment. Here is the fiddle: https://fiddle.sencha.com/#view/editor&fiddle/1uhg

In short, you need to calculate sum of all values and keep it outside of the renderer. On each render you count percentage and format it as you want.

renderer: function (value, metaData, record, rowIndex, colIndex, store) {
        var me = this;

        if (me.sum === 0) {
            store.getRange().forEach(function(rec) {
                me.sum += rec.get('value');
            } );
        }

        return Ext.util.Format.round(100*record.get('value')/me.sum, 0);
    }