【问题标题】:ExtJS 3.4 - Select row after load store of my gridpanelExtJS 3.4 - 在我的网格面板加载存储后选择行
【发布时间】:2015-05-05 15:26:41
【问题描述】:

我的网格面板:

new Ext.grid.GridPanel({
    title: "Utilisateurs",
    layout: 'fit',
    style: marginElement,
    columns: mesColonnesUtil,
    id: 'gridPanelUtil',
    width: '70%',
    colspan: 2,
    collapsible: false,
    layout: 'fit',
    autoWidth: true,
    monitorResize: true,
    height: 200,
    store: storeUtil,
    stripeRows: true,
    selModel: new Ext.grid.RowSelectionModel({
        singleSelect: true
    }),
    listeners: {
        click: function () {
            this.selModel.getSelected();
        }
    }
});

我的商店:

var storeUtil = new Ext.data.JsonStore({
    proxy: proxyGrUtil,
    baseParams: {
        method: 'storeUtil',
        gr: ''
    },
    autoLoad: true,
    fields: ["Nom", "Prenom", "LDAPUser"],
    root: "rows",
    totalProperty: "total",
    successProperty: "success"
});

我的combobox 带有选择事件,我用参数加载我的网格面板:

{
    xtype: 'combo',
    store: storeGrUtil,
    id: 'comboGrUtil_GrUtil',
    width: 300,
    valueField: "id",
    displayField: "lib",
    triggerAction: 'all',
    mode: 'local',
    listeners: {
        select: function () {
            Ext.getCmp('gridPanelUtil').store.load({
                params: {
                    gr: Ext.getCmp('comboGrUtil_GrUtil').getValue() // this the value of items selected combobox
                }
            })
        }
    }
}

在这个事件之后,我无法在我的网格面板中选择一行,为什么? 我不明白。

【问题讨论】:

  • 我投票结束这个问题,因为 Stack Overflow 是一个英文网站。
  • 即使谷歌翻译也能翻译:D 你写的法语内容很基础
  • 我投票结束这个问题,因为它是用法语而不是英语写的。

标签: extjs3


【解决方案1】:

问题是store的load事件的调用。您必须在此事件中而不是在调用之后执行行选择。如果我没记错的话,在这个事件中网格已经完全加载了。看看上面的代码标签。

如果它不起作用,我建议看看其他事件。也许用 gridView 的 rowinserted。

    var storeUtil = new Ext.data.JsonStore({    proxy: proxyGrUtil,
        baseParams: { method: 'storeUtil', gr: '' },
        autoLoad: true,
        fields: ["Nom", "Prenom", "LDAPUser"],
        root: "rows",
        totalProperty: "total",
        successProperty: "success",
        listeners: 
            load: function(e, records, options){
                 Ext.getCmp("gridPanelUtil").getSelectionModel().selectRow(maLigneASelectionner);
            }
        }
});

【讨论】:

    【解决方案2】:

    你需要使用网格的selectionModel,也许你可以在调用load到store的时候传递一个回调

    store.load({
        callback: function(records, operation, success) {
            //operation object contains all of the details of the load operation
            //records contains all the records loaded
            console.log(records);
        }
    });
    

    你可以打电话

    grid.getSelectionModel( ).select(object/index);
    //you need to pass record instance or index
    

    【讨论】:

      猜你喜欢
      • 2014-01-04
      • 1970-01-01
      • 2015-07-29
      • 1970-01-01
      • 2014-10-11
      • 1970-01-01
      • 1970-01-01
      • 2012-06-04
      • 1970-01-01
      相关资源
      最近更新 更多