Results 1 to 9 of 9

Thread: selecting first row of Grid

  1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    11

    Default selecting first row of Grid

    Hi All,
    I am new to Ext JS controls, need help for following
    --> I want to select first row of a grid after loading data
    --> how to show first group expanded and rest collapsed in Grouping grid. If I set
    Code:
    startCollapsed:true
    it will collapsed all groups, I want collapse all groups but except first one. how to achieve this?


    Thanks,
    Harsh

  2. #2
    Sencha User sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,335
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    11

    Default

    I tried this code, but it is giving me error -

    Code:
    var oGrid=document.getElementById('myGrid');
    oGrid.RowSelectionModel().selectFirstRow();
    Thanks,
    Harsh

  4. #4
    Sencha User
    Join Date
    Jan 2011
    Posts
    549

    Default

    Try something like the following:

    Code:
    var examplegrid = {    
        id:'examplegrid',
        xtype:'grid',
        store: store,
        columns: columns,
        listeners: {
            viewready: function(thisGrid) {
                thisGrid.getSelectionModel().selectFirstRow();
            }
        }
    };

  5. #5
    Sencha User
    Join Date
    Jul 2012
    Posts
    11

    Default

    I am trying to select first row from java script, but i am getting error 'object doesn't support this property or method' at ' oGrid.RowSelectionModel().selectFirstRow();' line

    also , I am getting error if try to access view object -
    Code:
    grid.getView()

  6. #6
    Sencha User
    Join Date
    Jan 2011
    Posts
    549

    Default

    You cannot run EXT functions on normal DOM elements, you have to either reference them by their defined variable names, or via:
    Code:
    var grid = Ext.getCmp('ID_of_the_EXT_object');
    Only once you have an EXT object as the variable can you then run EXT functions against them.

  7. #7
    Sencha User
    Join Date
    Jul 2012
    Posts
    11

    Default

    Thanks willigogs , it is working.

  8. #8
    Sencha User
    Join Date
    Dec 2011
    Posts
    6

    Default

    This doesn't work for me. I get 'TypeError: Object [object Object] has no method 'selectFirstRow''

  9. #9

    Default

    try this one:
    grid.getSelectionModel().select(0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •