【问题标题】:ExtJs 4.2 : how renderer this combobox with store.queryExtJs 4.2:如何用 store.query 渲染这个组合框
【发布时间】:2014-10-02 02:31:34
【问题描述】:

我的应用程序在 MVC 中。

我有一个带有列的网格,其中一个列有一个带有渲染器的列。当用户单击其他网格时,此网格会打开。

当我加载我的应用程序并单击以打开此网格时,此列(以及之后的其他列)不会加载。但是当我关闭并重新打开此网格时,会加载列。 不知道问题出在哪里(而且,这个问题并没有出现在开发服务器上……)

我做了一个console.log(Ext.getStore('sTypesJours')):我有一些记录

然后我做了一个console.log(Ext.getStore('sTypesJours').query('uid', val, false, false, true)):我第一次没有记录,但重新打开后它可以工作......

这是我的网格的代码:

Ext.define('KGest.view.grille.Modif', {
    extend: 'Ext.grid.Panel',
    xtype: 'grillemodif',
    title: 'Elements déjà saisis',
    store: 'sGrilleModif',
    dockedItems: [
        {
            xtype: 'toolbar',
            dock: 'bottom',
            itemId: 'toptoolbarService',
            items: [
                {
                    xtype: 'button',
                    id: 'save-button-grillemodif',
                    text: 'Sauver les modifications',
                    iconCls: 'x-icon-save',
                    action: 'update',
                    dock: 'top',
                    scope: this
                }
            ]
        }
    ],
    selType: 'rowmodel',
    plugins: [
        Ext.create('Ext.grid.plugin.CellEditing', {
            clicksToEdit: 1
        })
    ],
    columnLines: true,
    viewConfig: {
        deferEmptyText: false,
        emptyText: 'Aucune donnée déjà saisie'
    },
    initComponent: function() {
        var me = this;

        me.selModel = Ext.create('Ext.selection.CheckboxModel', {
            listeners: {
                selectionchange: function(sm, selections) {
                    Ext.getCmp('validall-button-grillemodif').setDisabled(selections.length === 0);
                    Ext.getCmp('supprall-button-grillemodif').setDisabled(selections.length === 0);
                }
            },
            injectCheckbox: 7    // position de la colonne des checkbox
        });

        Ext.apply(me, {
            columns: [
                {
                    text: 'Journée',
                    dataIndex: 'journee',
                    allowBlank: false,
                    xtype: 'datecolumn',
                    format: 'd/m/Y',
                    width: 100,
                    editor: {
                        xtype: 'datefield',
                        submitFormat: 'Y-m-d'
                    }
                },
                {
                    text: 'Type de jour',
                    dataIndex: 'uid_types_saisies',
                    flex: 1,
                    editor: {
                        xtype: 'combobox',
                        store: Ext.create('KGest.store.sTypesJours'),
                        valueField: 'uid',
                        displayField: 'libelle',
                        typeAhead: true,
                        queryMode: 'remote',
                        emptyText: 'Sélectionnez un type de jour',
                        listeners: {
                            beforequery: function(queryEvent, eOpts) {
                                var tabFilter = new Array();
                                tabFilter[0] = {"property": "uid_salaries", "value": Ext.getCmp('uid_salaries').getValue()};
                                queryEvent.combo.store.proxy.extraParams.filter = JSON.stringify(tabFilter);
                            }
                        }
                    },
                    renderer: function(val) {
                        if (val > 0) {
                            var srvStore = Ext.getStore('sTypesJours');
                            detail = srvStore.query('uid', val, false, false, true);
                            sortie = detail.getAt(0).data.code;
                        }
                        return sortie;
                    }
                },
                {
                    text: '1/2<br/>jour',
                    dataIndex: 'demi_jour',
                    xtype: 'checkcolumn',
                    width: 50
                }
            ]
        });
        me.callParent(arguments);
    }
});

有人有什么想法吗?

【问题讨论】:

    标签: extjs store extjs4.2


    【解决方案1】:

    我能提供的最好的(提问后 6 个月)是这样的:

    时间就是一切,“渲染器”字段在 onload() 时间格式化单元格数据 - 同时,在渲染器函数中实例化和检索数据到存储区(当存储阵列尚未填充时)返回未定义,到下一次网格加载发生时,瞧,有填充的商店,你从查询中得到结果.. 可能很久以前就解决了这个问题,但是加载存储(自动加载:true)或在网格定义范围之外实例化“存储”(在调用布局/渲染器之前)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-28
      • 2014-07-21
      • 1970-01-01
      • 2019-10-05
      相关资源
      最近更新 更多