Results 1 to 4 of 4

Thread: [3.0] List View XTemplate row number

  1. #1
    Sencha User
    Join Date
    Nov 2007
    Posts
    243

    Default [3.0] List View XTemplate row number

    How do i get the row number in the tpl: config for a list view column? I tried {[xindex]} & parent.xindex but neither worked. Any ideas?

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    You can't access the parent, because it uses a subtemplate.

    Instead, you could modify the ListView tpl, e.g.
    Code:
    new Ext.ListView({
        tpl: new Ext.XTemplate(
            '<tpl for="rows">',
                '<tpl exec="values.row = xindex;"></tpl>',
                '<dl>',
                    '<tpl for="parent.columns">',
                    '<dt style="width:{width}%;text-align:{align};"><em unselectable="on">',
                        '{[values.tpl.apply(parent)]}',
                    '</em></dt>',
                    '</tpl>',
                    '<div class="x-clear"></div>',
                '</dl>',
            '</tpl>'
        ),
        columns: [{
            header: '#',
            dataIndex: 'row'
        },{
            header: 'Text',
            dataIndex: 'field1'
        }],
        store: ['One', 'Two', 'Three'],
        width: 200,
        height: 200,
        renderTo: Ext.getBody()
    });

  3. #3
    Sencha User
    Join Date
    Nov 2007
    Posts
    243

    Default

    Worked perfect - cheers Condor! Those XTemplates really are powerful, but take a bit to get ya head around! Thanks again!

  4. #4
    Sencha Premium Member
    Join Date
    Oct 2009
    Posts
    19

    Default

    How would something similar work if the listview was an extension - it seems like adding a row counter to list view would
    be useful... but the method above applied causes the viewlist to show only headers - so I must be missing some part of
    using it in an extend.
    ListViewWithRows = Ext.extend(Ext.list.ListView, {

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •