JuX_x
JuX_x

Reputation: 31

ExtJS 3.4 - Select row after load store of my gridpanel

My grid panel:

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();
        }
    }
});

My store:

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

My combobox with select event, I load my grid panel with params:

{
    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
                }
            })
        }
    }
}

After this event, I can't select a row in my grid panel, why ? I don't understand.

Upvotes: 3

Views: 3332

Answers (2)

Castro Roy
Castro Roy

Reputation: 7803

you need to use the selectionModel of the grid, maybe you can pass a callback when calling load to the 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);
    }
});

the you can call

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

Upvotes: 0

Michael
Michael

Reputation: 1193

The problem is the call of the load event of the store. You have to execute the row selection in this event and not after the call. If I remember well, the grid is completely loaded in this event. Take a look of the code tag above.

If it not working, I suggest to take a look at other event. Maybe with rowinserted of the gridView.

    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);
            }
        }
});

Upvotes: 0

Related Questions