serg
serg

Reputation: 111265

How to access other record fields inside grid's widgetcolumn in Extjs6?

I have a grid with a progressbar widget column:

{
    xtype    : 'widgetcolumn',
    dataIndex: 'progress',
    widget: {
        xtype: 'progressbarwidget',
        textTpl: [
            '{percent:number("0")}% done'
        ]
    }
}

How can I change textTpl to be something like {record.data.field1} out of {record.data.field2}, it seems that only current column value is being accessible.

See http://examples.sencha.com/extjs/6.0.1/examples/kitchensink/#widget-grid

Upvotes: 0

Views: 1001

Answers (1)

Alexander
Alexander

Reputation: 20224

If you have a look into the progressbarwidget code, your fear is well founded.

updateValue: function(value, oldValue) {
    ...
    if (textTpl) {
        me.setText(textTpl.apply({
            value: value,
            percent: Math.round(value * 100)
        }));
    }

You would have to extend that class, override the updateValue function, and use something like this:

me.setText(textTpl.apply({
    value: value,
    percent: Math.round(value * 100),
    record: me.$widgetRecord
}));

and there you go.

Upvotes: 1

Related Questions