1. #1
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default Ext.ux.grid.PagingRowNumberer

    Ext.ux.grid.PagingRowNumberer


    here's a PagingRowNumberer for use with paging grids -- numbers increment with pagination instead of restarting from 1.
    use it the same way you would a RowNumberer
    Code:
    Ext.ns('Ext.ux.grid');
    
    // custom RowNumberer for use with paging GridPanels
    Ext.ux.grid.PagingRowNumberer = Ext.extend(Ext.grid.RowNumberer, {
        renderer: function(v, p, record, rowIndex, colIndex, store) {
            if (this.rowspan) {
                p.cellAttr = 'rowspan="' + this.rowspan + '"';
            }
    
            var so = store.lastOptions;
            var sop = so ? so.params: null;
            return ((sop && sop.start) ? sop.start: 0) + rowIndex + 1;
        }
    });
    enjoy

  2. #2
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,538
    Vote Rating
    380
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Great!

    It can come handy in many situations.

    One question: I guess numbering is independent of sorting, right? In another words, does the same row get (possibly) another number when sorting changes?
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  3. #3
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    yep. numbering is independent of sorting.

    number order remains the same no matter how the grid is sorted.

  4. #4
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Awesome work as usual Mystix!!

  5. #5
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    lest i forget...

    one little caveat with both the RowNumberer and PagingRowNumberer:
    if Records are dynamically added / removed from the Store, the row numbers are not updated.

    a GridView refresh must be forced in order to update the row numbers, like so
    Code:
    var myGridView = mygrid.getView();
    myGridView.refresh(); // update row numbers

  6. #6
    Sencha User
    Join Date
    Mar 2007
    Posts
    42
    Vote Rating
    0
    benny00 is on a distinguished road

      0  

    Default


    Many thanks! Just what I needed!
    One little thing though:

    PHP Code:
    Ext.ux.grid.PagingRowNumberer Ext.extend(Ext.grid.RowNumberer, { 
    should be:
    PHP Code:
    Ext.ux.PagingRowNumberer Ext.extend(Ext.grid.RowNumberer, { 

  7. #7
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    Quote Originally Posted by benny00 View Post
    should be:
    PHP Code:
    Ext.ux.PagingRowNumberer Ext.extend(Ext.grid.RowNumberer, { 
    i deliberately placed it in the Ext.ux.grid namespace, to mirror the Ext.grid.RowNumberer which this plugin extends.
    feel free to modify the namespace to suit your needs.

  8. #8

  9. #9
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    rest assured i'm sucking my thumb now.

    oh well. should have searched before i posted. back to the drawing board.

    [edit]
    hmmm... if i could solve the fixed column width problem, then i wouldn't have to suck my thumb any more...
    i'll look into it when i get some time on my hands.

  10. #10
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Stupid question. Couldn't all of the page numbers be done on the server side? We all pass a start && limit to the server. It could easily do the math and append 'row number' to the returning dataset.

    Thoughts?