1. #1
    Ext User
    Join Date
    Jul 2007
    Posts
    15
    Vote Rating
    0
    newinext is on a distinguished road

      0  

    Default Grid line numbers column ?

    Grid line numbers column ?


    Hi !
    I need a column in the grid that displays the number of the row (1,2,3...).
    This column will not change if I sort the other columns.
    Is this feature implemented in ext grid ? anyone has an idea ?
    Thanx in advance

  2. #2
    Sencha Developer
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    482
    Vote Rating
    1
    Wolfgang is on a distinguished road

      0  

    Default


    Quote Originally Posted by newinext View Post
    Hi !
    I need a column in the grid that displays the number of the row (1,2,3...).
    This column will not change if I sort the other columns.
    Is this feature implemented in ext grid ? anyone has an idea ?
    Thanx in advance
    What do you mean with 'the number of the rows' in relation to 'will not change if I sort the other columns'?

    The grid column number is based on the column position starting with 0.
    Also each record has its own internal id in the datastore.
    ...And of cause it depends on how you sort.

    If you need a unique id field for each record, then you need to add this to your record set.
    How should ext otherwise assign this id, given you can do paging?

    Regards

    Wolfgang

  3. #3
    Ext User
    Join Date
    Jul 2007
    Posts
    15
    Vote Rating
    0
    newinext is on a distinguished road

      0  

    Default


    thanx for your reply
    What I meant is a displayed column in the grid. It will be used my the final user displaying the line numbers.

    If I have another column let's say name, if I sort the names, the column line number still displayed 1,2,3 in order.

    example :
    http://www.activewidgets.com/grid/
    You see here the colum before the ticker's column.

    I hope I expressed well what I wanted !
    Thanx in advance

  4. #4
    Sencha Developer
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    482
    Vote Rating
    1
    Wolfgang is on a distinguished road

      1  

    Default


    In the example of the other website, the id changes when changing the sort order.
    Is this what you want?

    If so, than have a look here:
    http://extjs.com/forum/showthread.php?t=9468
    There is a discussion of how to add a field that is calulated and not part of the data store.
    So what you need is a "custom renderer" and to return the "rowIndex" in your renderer.

    Regards

    Wolfgang

  5. #5
    Ext User
    Join Date
    Jul 2007
    Posts
    15
    Vote Rating
    0
    newinext is on a distinguished road

      0  

    Default


    I returned rowIndex in the renderer function, it works well, when I sorted the other column, my column row line number keeps the initial order
    THANX VERY MUCH WOLF !!!

  6. #6
    Ext User
    Join Date
    Jul 2007
    Posts
    10
    Vote Rating
    0
    rogrdat is on a distinguished road

      0  

    Default


    I have an field named 'id' in the JSON payload which I would like to display as the Grid Row/Line #. A simple mapping such as
    {header:"#", dataIndex:"id",...,}
    didn't seem to work. Wolfgang any pointers ??

    thanks,

  7. #7
    Sencha Developer
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    482
    Vote Rating
    1
    Wolfgang is on a distinguished road

      0  

    Default


    Mhh that should work.

    Here what works for me.
    PHP Code:
    cm = new Ext.grid.ColumnModel([
        {
    id'id'dataIndex'id'header'#'width30},
    ... 
    Regards

    Wolfgang

  8. #8
    Ext User
    Join Date
    Jul 2007
    Posts
    10
    Vote Rating
    0
    rogrdat is on a distinguished road

      0  

    Default


    Wolfgang, thanks for hte reply. My mistake was that I had assumed that "id" wasn't required to defined in the record definition for the grid. That addressed the issue,

    thanks,

  9. #9
    Ext User
    Join Date
    May 2007
    Posts
    69
    Vote Rating
    0
    mfw24 is on a distinguished road

      0  

    Default Can you post code?

    Can you post code?


    Newinext- would you mind posting the custom render funciton you used to create the row numbers?

  10. #10
    Ext User
    Join Date
    Feb 2008
    Posts
    4
    Vote Rating
    0
    pedro123penduko is on a distinguished road

      0  

    Default


    It's been a long time..
    Did you found a fix for the line numbers?

    If not, check out "Class Ext.grid.RowNumberer" on the API DOcs