1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    38
    Vote Rating
    0
    jovasnimaro is on a distinguished road

      0  

    Default Grid and selectionModel()

    Grid and selectionModel()


    Hi, i tried to select all the rows of a grid but only select the last row,

    my code is the next:
    Code:
    Ext.getCmp('gridsites').getSelectionModel().selectAll();
    var sm = Ext.getCmp('gridsites').getSelectionModel().getSelection();
    console.log(sm.length);
    console.log(sm);
    images:

    Capture1.PNGCapture2.PNG

    in the console image can see that the length of the variable is 1 when really should be 11 , and the information of the sm variable shows that only take the last row.

    Regards.

    Jovani

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,197
    Vote Rating
    482
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Do you have multiSelect: true set in your grid?

    Code:
    Ext.create('Ext.data.Store', {
        storeId : 'simpsonsStore',
        fields  : ['name', 'email', 'change'],
        data    : {'items' : [
            { 'name' : 'Lisa',  'email' : 'lisa@simpsons.com',  'change' : 100  },
            { 'name' : 'Bart',  'email' : 'bart@simpsons.com',  'change' : -20  },
            { 'name' : 'Homer', 'email' : 'home@simpsons.com',  'change' : 23   },
            { 'name' : 'Marge', 'email' : 'marge@simpsons.com', 'change' : -11  }
        ]},
        proxy   : {
            type   : 'memory',
            reader : {
                type : 'json',
                root : 'items'
            }
        }
    });
    
    var grid = Ext.create('Ext.grid.Panel', {
        title      : 'Simpsons',
        multiSelect: true,
        store      : Ext.data.StoreManager.lookup('simpsonsStore'),
        columns    : [
            { header : 'Name', dataIndex : 'name' },
            { header : 'Email', dataIndex : 'email', flex : 1 },
            { header : 'Change', dataIndex : 'change' }
        ],
        height     : 200,
        width      : 400,
        renderTo   : Ext.getBody()
    });
    
    grid.getSelectionModel().selectAll();
    var selected = grid.getSelectionModel().getSelection();
    console.log(selected.length); // returns 4
    Scott.

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    38
    Vote Rating
    0
    jovasnimaro is on a distinguished road

      0  

    Default


    No, i add the property and it works.

    Thanks.

    Jovani

Thread Participants: 1

Tags for this Thread