1. #1
    Ext User
    Join Date
    Aug 2009
    Posts
    3
    Vote Rating
    0
    showker is on a distinguished road

      0  

    Exclamation How to write Javascript in groupTextTpl of groupview?

    How to write Javascript in groupTextTpl of groupview?


    I have a groupview like this:
    new Ext.grid.GroupingView({
    forceFit:true,
    itemSelector: 'totalEffectPv',
    groupTextTpl: '{text} ( {["TotalOfThisGroup:"]} {[values.rs[0].data.totalEffectPv])'
    frame:true,
    collapsible: true,
    animCollapse: false,
    width:700,
    height:280
    });
    I can get the first row of each group which will show in the groupTextTpl.But now I want to show the total of the "totalEffectPv" field (not the row count).For example the ‘totalEffectPv' of the first group is
    10
    20
    30
    Now I want the groupTextTpl=60. So I try a js loop in the "groupTextTpl" like this:
    groupTextTpl: '{text} ( {["TotalOfThisGroup:"]} {[var total;for(var i in values.rs) {total=i.data.totalEffectPv;total++;} return total;}])'

    But this doesn't work.So how can i write this js????where to write?

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    87
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You can specify a full XTemplate in startGroup instead of only a string in groupTextTpl, e.g.
    Code:
    startGroup: new Ext.XTemplate(
      '<div id="{groupId}" class="x-grid-group {cls}">',
      '<div id="{groupId}-hd" class="x-grid-group-hd" style="{style}"><div class="x-grid-group-title">',
      '{text} (total: {this.calcTotal})',
      '</div></div><div id="{groupId}-bd" class="x-grid-group-body">',
      {
        calcTotal: function(values){
          for(var sum = 0, i = 0, len = values.rs.length; i < len; i++){
            sum += values.rs[i].get('totalEffectPv');
          }
          return sum;
        }
      }
    )

  3. #3
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    673
    Vote Rating
    20
    carol.ext will become famous soon enough carol.ext will become famous soon enough

      0  

    Default


    Create a function outside of the template to do the summing and call the function in the "code" part of the template, passing the data in (values.rs). Make sure the function is visible when it is needed.

    Also, for in type loop not recommended.
    Last edited by carol.ext; 21 Oct 2009 at 9:38 AM. Reason: clarification

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."