Parameters for groupTextTpl

  • Hello Everyone,
    I have a grouping view working, but I would like to enhance a little bit :D
    My question is, how can I change the groupTextTpl option, to see the lei field instead lei_id ?

    var ds = new Ext.data.GroupingStore({
    proxy: new Ext.data.HttpProxy({url: '/pesquisa/lei_grid'}),
    reader: new Ext.data.JsonReader({
    root: 'ComponenteLei',
    totalProperty: 'Total',
    id: 'id'
    }, [
    {name: 'id',mapping: 'id'},
    {name: 'lei_id',mapping: 'lei_id'},
    {name: 'lei',mapping: 'lei'},
    {name: 'texto', mapping: 'texto'}
    ]),
    sortInfo:{field: 'id', direction: "ASC"},
    groupField:'lei_id'
    });
    var gview = new Ext.grid.GroupingView({
    forceFit:true,
    groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Artigos" : "Artigo"]})'
    });

    I tried:
    '{values.rs[0].lei} ({[values.rs.length]} {[values.rs.length > 1 ? "Artigos" : "Artigo"]})'
    but I got the text "values.rs[0].lei (1) Artigo".
    Thanks in advance !
    Sal


  • fangzhouxing,

    I don't know (I'm a newbie) , what I know is that the renderer will replace the {text} part of groupTextTpl. I didn't tried to use it without the groupTextTpl template.

    s...
    rosaldanha


  • Hi,

    Have a try with


    groupTextTpl: '{[ values.rs[0].data["storefieldname"] ]}'


    this should works

    P.S: remember to use inner the {} template markers.


  • Try something like that to check what type of field the grid is grouped by.

    groupTextTpl: 'storefieldname1 {text}' +
    'storefieldname2 {text}'

    Philou


  • Brilliant, been looking for that

    But is it possible to change the text template back to default once the user selects Group By this Field from one of the column headers


  • fangzhouxing,
    I found an workaround.
    I created a custom renderer for the lei_id field:

    var cm = new Ext.grid.ColumnModel
    ([
    {id: 'id', header: "id",dataIndex: 'id', width: 10,hidden:true},
    {header: "Lei",dataIndex: 'lei_id', width: 10, hidden:true, renderer: renderLei},
    {header: "",dataIndex: 'texto', width:250, renderer: renderArtigo}

    ]);
    // this custom renderer will show what I need, the "lei_nome" field instead the lei_id field.
    function renderLei(value, p, record){
    return String.format('{0} Vigência:({1})', record.data.lei_nome,record.data.vigencialei);
    }


  • rosaldanha,thank you for reply.

    We don't need special groupTextTpl, just define custom renderer for groupField. Am I right?


  • I have searched the forum about groupTextTpl, and nobody tell the usage of groupTextTpl yet.

    Can anyone help?


  • Hi,

    Have a try with


    groupTextTpl: '{[ values.rs[0].data["storefieldname"] ]}'


    this should works

    P.S: remember to use inner the {} template markers.

    works great! thank you! ;)


  • Brilliant, been looking for that

    But is it possible to change the text template back to default once the user selects Group By this Field from one of the column headers

    Ok i'm a dude, but i'm not sure what do you mean...


  • I want to be able to check what type of field the grid is grouped by and display different info in the group header depending on that.

    Can't you add the groupField in groupTextTpl as parameter in future release? It would be really nice feature to have.

    Thanks,
    Daniel W







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Parameters for groupTextTpl , Please add it free.