1. #1
    Ext JS Premium Member
    Join Date
    Aug 2007
    Posts
    14
    Vote Rating
    0
    Layne is on a distinguished road

      0  

    Default How Do You Get a Row Number in a Grid

    How Do You Get a Row Number in a Grid


    How do you get the row number (or index) of a row in a grid? I'm trying to do something in a column model renderer function (config). I've seen reference to "rowIndex", but haven't figured out how to access it.

    (I'm not looking to number the rows - like RowNumberer. Nor am I looking for the row number of a selected row).

    Any suggestions would be appreciated.

  2. #2
    Sencha User catacaustic's Avatar
    Join Date
    Jul 2007
    Location
    "A Land Down Under"
    Posts
    618
    Vote Rating
    1
    catacaustic is on a distinguished road

      0  

    Default


    How you get the row number depends on the event that you're basing it on. Grid events like cellclick and rowclick get called with the row number, so you can easily take it from there.

    If you're looking at something else, use the index of the record in the data store. This corresponds to the row number in the grid as grid rows are taken directly from the data store in order.
    'Once again, fortune vomits on my eiderdown'
    - Edmund Blackadder

  3. #3
    Ext User
    Join Date
    Nov 2007
    Posts
    22
    Vote Rating
    0
    rufinus is on a distinguished road

      0  

    Default


    Code:
    	grid.on('rowdblclick', function(grid, rowIndex, e) {	
    	var selectedId = ds.getAt(rowIndex).id;
    	});
    where 'ds' is the datastore.

    Rufinus

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    83
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    rowIndex is the fourth parameter in a renderer function (see API docs).

  5. #5
    Ext User
    Join Date
    Mar 2008
    Posts
    63
    Vote Rating
    0
    zab is on a distinguished road

      0  

    Default


    Quote Originally Posted by catacaustic View Post
    If you're looking at something else, use the index of the record in the data store. This corresponds to the row number in the grid as grid rows are taken directly from the data store in order.
    but API I didn't find any method to get the index of a record in the data store... How can we get it?

  6. #6
    Ext User
    Join Date
    Mar 2008
    Posts
    63
    Vote Rating
    0
    zab is on a distinguished road

      0  

    Default


    sorry, I just find it : there is a method "store.indexOf(record)"