ExtJS - 'combocolumn' based renderer - row

2019-09-17 14:33发布

问题:

http://2gears.com/2011/05/combobox-editor-remote-and-renderer-for-extjs-editorgridpanel/comment-page-2/#comment-11050?

Please see the function.

I am not using the 'combocolumn' completely. However i have used the major components. Please advise if there is a possibility it should work. As of now the grid refuses to render the column itself and I am unable to pinpoint what the bug is as the code is simply the same? I did this not to act smart :) - but to simplify and run it on 1 column before standardizing the component common to the project.

The COMBO RENDERING fn()

<code>
function ComboBoxRenderer(combo, gridId) {

    var getValue = function (value) {
        var idx = combo.store.find(combo.valueField, value);
        var rec = combo.store.getAt(idx);
        if (rec) {
            return rec.get(combo.displayField);
        }
        return value;
    };

    return function (value) {
        if (combo.store.getCount() === 0 && gridId) {
            console.log(combo.store.getCount()+gridId);
            combo.store.on(
                    'load',
                    function () {
                        var grid = Ext.getCmp(gridId);
                        if (grid) {
                            grid.getView().refresh();
                        }
                    },
                    {
                        single: true
                    }
            );
            return value;
        }

        return getValue(value);
    };
//    Ext.getCmp(gridId).getView().refresh();
}
</code>

Editor - in Grid Column Model

{ header: 'Plan Type', dataIndex: 'plan_id', editor: { // allowBlank: 'false', xtype: 'combobox', queryMode: 'local', store: planTypeStore, displayField: 'plan_name', valueField: 'plan_id' } ,renderer: ComboBoxRenderer(this.editor, 'gridPanelId') /*this is the docs based renderrer - which wont work */ //, renderer: function (val) { // var rec = planTypeStore.findRecord('plan_id', val); // return (rec !== null ? rec.get("plan_name") : ''); // }

标签: Extjs