0

I am trying to select the first row in a grid:

Ext.getCmp('myGrid').getSelectionModel.select(0);

I got an error saying select is undefined

enter image description here

but I can see the function exists.

I was using the ExtJS 4.2 version and I had no problem with that, now I am using the 6.5 version and I got that error.

What could be the problem here?

--EDIT--

Basically I have a function to create the store:

CreateDataStore: function (result, id) {
    Ext.define('DDM', {
        extend: 'Ext.data.Model',
        fields: result.FieldColumns
    });

    var dataRecords = JSON.parse(result.Records);

    return Ext.create('Ext.data.Store', {
        id: id,
        autoLoad: true,
        model: 'DDM',
        data: dataRecords,
        remoteSort: false,
        fields: result.Fields
    });
}

And another function to assign the store to the grid and select the first row:

function BindDataGrid(result) {
 gridStore = CreateDataStore(result, 'myGridStore');
 Ext.getCmp('myGrid').reconfigure(gridStore);
 if (Ext.getCmp('myGrid').getStore().getCount() > 0)             
  Ext.getCmp('myGrid').getSelectionModel().select(0);
}
Juan Alberto
  • 165
  • 3
  • 18
  • I made a fiddle using ExtJs6 Classic: https://fiddle.sencha.com/#view/editor&fiddle/2uqg It is working as expected. Maybe you can show more of your code? – marset Aug 22 '19 at 18:22
  • I added the functions that I am using. Thanks for the fiddle, I don't know why is not working on my project just like that.I tried this: Ext.getCmp('myGrid').selModel.select(0), and it works, but I still would want to know what is wrong with the first approach. – Juan Alberto Aug 22 '19 at 22:41
  • from a rough view on the select method here: https://docs.sencha.com/extjs/6.5.3/classic/src/Model.js-1.html#Ext.selection.Model-method-select , nothing (undefined) is returned. please share more code that we can try to figure it out whats not working. – hwsw Aug 23 '19 at 16:28

0 Answers0