【问题标题】:dynamic store in column grid editable列网格中的动态存储可编辑
【发布时间】:2016-11-03 22:39:16
【问题描述】:

在可编辑的网格列中(ExtJs v4.2.2),如何动态更改存储? 关键是按运动类型(movementTypeId)加载具有不同参数的商店:

要附加的不同列表的字段是“原因”,列是:

this.columns = [
{
    text: 'id',
    dataIndex: 'movementId',
    sortable: false,
    hideable: true,
    sortableColumn: false,
    hidden: true,
    flex : 1,
    scope:this
},
{
    text: 'TypeId',
    dataIndex: 'movementTypeId',
    sortable: false,
    sortableColumn: false,
    hideable: true,
    sortableColumns: false,
    hidden: true,
    flex : 2,
    scope:this
},

{
    text: 'Reason',
    dataIndex: 'movementReasonId',
    sortable: false,
    hideable: true,
    sortableColumn: false,
    field: {
        xtype: 'combobox',
        align: 'center',
        typeAhead: true,
        triggerAction: 'all',
        //selectOnTab: true,
        store: this.storeMovementReasonType,
        displayField: 'label'
    },
    flex : 3,
    scope:this
},

];

所以对于每一行,当存储加载时想要设置额外的参数,如:

if(movementTypeId === 89){
 storeMovementReasonType.getProxy().setExtraParam('dictionaryTypeId',11);
 }
 if(movementTypeId === 94){
    storeMovementReasonType.getProxy().setExtraParam('dictionaryTypeId',8);
 }

有可能吗? 谢谢你的时间:)

【问题讨论】:

    标签: extjs grid store


    【解决方案1】:

    您想在您的行编辑插件上实现beforeedit 侦听器:

    listeners:{
        beforeedit:function(editor , context , eOpts) {
            var movementTypeId = context.record.get("movementTypeId");
            if(movementTypeId === 89){
                storeMovementReasonType.getProxy().setExtraParam('dictionaryTypeId',11);
            }
            if(movementTypeId === 94){
                storeMovementReasonType.getProxy().setExtraParam('dictionaryTypeId',8);
            }
            storeMovementReasonType.load();
        }
    }
    

    【讨论】:

    • 我也必须在网格上显示商店的字段值。我正在使用渲染器,并在返回标签之前等待商店加载,但是渲染器方法不等待返回..你有什么想法吗?
    • @aurny2420289 Hanc marginis exiguitas non caperet.
    猜你喜欢
    • 2013-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-30
    • 1970-01-01
    • 2012-02-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多