1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    43
    Vote Rating
    0
    pk.hafeez is on a distinguished road

      0  

    Default Unanswered: How to add row number column in a grid panel

    Unanswered: How to add row number column in a grid panel


    I have a grid panel. I have configured the column model. Loading some data for the grid from server side. Now, i have got a requirement to display an extra column in the grid which will show row number. I have pagination tool bar, column filters. Any help will be great
    Note : Data is huge in thousands

  2. #2
    Sencha User
    Join Date
    Oct 2009
    Posts
    95
    Answers
    3
    Vote Rating
    1
    Albareto is on a distinguished road

      0  

    Default


    Add a new column with a renderer:
    Code:
    {
        text : 'row',
        dataIndex: 'rowIndex',
        sortable : false,
        // other config you need..
        renderer : function(value, metaData, record, rowIndex)
        {
            return rowIndex;
        }
    }

  3. #3
    Sencha User
    Join Date
    Apr 2011
    Posts
    43
    Vote Rating
    0
    pk.hafeez is on a distinguished road

      0  

    Default


    Thanks. Almost got it. But i have a pagination on the grid. so when i go to the next page, the number should start from then on. Not from zero(0) again. !!

  4. #4
    Sencha User
    Join Date
    Oct 2009
    Posts
    95
    Answers
    3
    Vote Rating
    1
    Albareto is on a distinguished road

      0  

    Default


    In the store there is something like start or something like that when you have pagination, just add it to your value

    Code:
    {  
        text : 'row',
         dataIndex: 'rowIndex',
         sortable : false,    
        // other config you need.. 
        renderer : function(value, metaData, record, rowIndex, colIndex, store)    
        {
             return store.start + rowIndex;     
        }
     }
    You can debug the store to get the exact name of that field, but I think it is start.

  5. #5
    Sencha User
    Join Date
    Apr 2011
    Posts
    43
    Vote Rating
    0
    pk.hafeez is on a distinguished road

      0  

    Default


    Hi,

    I couldn't find any start field on store. so instead i did it this way. i got the page no and did some calculation.
    var rowNumberRenderer = function(value, metaData, record, rowIndex){
    var pageIndex = $(".x-tbar-page-number .x-form-field").val();
    var recordsPerPage = 50;
    if(Ext.getCmp('myPagingId').getValue() != null && Ext.getCmp('myPagingId').getValue() != undefined){
    recordsPerPage = Ext.getCmp('myPagingId').getValue();
    }
    return (pageIndex-1)*recordsPerPage+rowIndex+1;
    };

    columns : [{
    header : '',
    dataIndex: 'rowIndex',
    width:15,
    sortable : true,
    // other config you need..
    renderer : rowNumberRenderer
    }]

  6. #6
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Answers
    16
    Vote Rating
    13
    flanders will become famous soon enough

      0  

    Default


    Is there any reason you are not using the build in RowNumberer?

    EDIT: The message editor for this forum provides you with CODE tags. If you use those people can actually read your code

  7. #7
    Sencha User
    Join Date
    Apr 2011
    Posts
    43
    Vote Rating
    0
    pk.hafeez is on a distinguished road

      0  

    Default


    Both renderer and xtype:rownumberrenderer make the no's start from 1 when you navigate to the next page. So, probably i will use the custom rownumber renderer.

  8. #8
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Answers
    16
    Vote Rating
    13
    flanders will become famous soon enough

      0  

    Default


    Hmmz, really? I thought the rownumberer used the totalCount. See for example:

    http://docs.sencha.com/ext-js/4-1/source/RowNumberer.html#Ext-grid-RowNumberer
    (The render method uses store.indexOfTotal)

    http://docs.sencha.com/ext-js/4-1/#!...d-indexOfTotal
    This method should number over the whole

    Weird, but I have no access to an example at the moment so can't test it for myself.

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar