1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    11
    Vote Rating
    0
    harshp is on a distinguished road

      0  

    Default selecting first row of Grid

    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 - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    11
    Vote Rating
    0
    harshp is on a distinguished road

      0  

    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
    546
    Vote Rating
    53
    willigogs is a jewel in the rough willigogs is a jewel in the rough willigogs is a jewel in the rough

      0  

    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
    Vote Rating
    0
    harshp is on a distinguished road

      0  

    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
    546
    Vote Rating
    53
    willigogs is a jewel in the rough willigogs is a jewel in the rough willigogs is a jewel in the rough

      0  

    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
    Vote Rating
    0
    harshp is on a distinguished road

      0  

    Default


    Thanks willigogs , it is working.

  8. #8
    Sencha User
    Join Date
    Dec 2011
    Posts
    6
    Vote Rating
    0
    Jerinaw is on a distinguished road

      0  

    Default


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