1. #1
    Touch Premium Member
    Join Date
    Jan 2009
    Posts
    58
    Vote Rating
    1
    Designworxz is on a distinguished road

      0  

    Exclamation Sum of Values in Xtemplate

    Sum of Values in Xtemplate


    How to do total in Xtemplate as in Gridview.
    Code:
    	tpl = new Ext.XTemplate(
             '<tpl for=".">',
    		   '<div>',
              			'<tpl if="selected">',
    							'<div class="left">',
    								'${SalesPrice}',
    							'</div>',							
    			 '</tpl>',
    	    '</div>',
           //------------------> Want to display total of SalesPrice Here
    	   '</tpl>'
        );

  2. #2
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    XTemplates allows you ho handle your data just enclosing this kind of operations between {[ .. ]} brackets.
    So, just to explain better what I mean, suppose your model has two fields (numberA and number.
    To sum these values inside your template you should code it in something like:

    Code:
    var tpl = new Ext.XTemplate(
    	'<tpl for=".">',
    		'First Number: {numberA}',
    		'Second Number: {numberB}',
    		'SUM: {[values.numberA + values.numberB]}',
    	'</tpl>'
    );
    Hope this helps.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  3. #3
    Touch Premium Member
    Join Date
    Jan 2009
    Posts
    58
    Vote Rating
    1
    Designworxz is on a distinguished road

      0  

    Default


    Thanks for prompt reply Andrea, but i need total. My Store is like this
    Code:
    
        store = new Ext.data.Store({
                        model: "Store.models.mod",
                        data:[
                                { Code : "001", SalePrice: "2300", selected: true},
                                { Code : "002", SalePrice: "245", selected: false},
                                { Code : "003", SalePrice: "2456", selected: true},
                                { Code : "004", SalePrice: "1345", selected: true}
                            ]    
      });
    Xtemplate when rendered should display like this

    Code:
       Code: 001     SalePrice: 2300
    -------------------------------------
       Code: 003     SalePrice: 2456
    -------------------------------------
       Code: 004     SalePrice: 1345
    -------------------------------------
    Total:                      6101

  4. #4
    Touch Premium Member
    Join Date
    Jan 2009
    Posts
    58
    Vote Rating
    1
    Designworxz is on a distinguished road

      0  

    Default


    Anybody ?

  5. #5
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    2
    Vote Rating
    0
    tbd.work is on a distinguished road

      0  

    Default Probably too late to help OP, but I found an answer for this

    Probably too late to help OP, but I found an answer for this


    I just had the same requirement, found this post and was upset to realize there was no answer on it!

    You can get access to the array of data by passing down values. Ie.

    tpl: new Ext.XTemplate(
    '<tpl for=".">
    {price}
    </tpl>
    {[this.getTotal(values)]}',
    function getTotal(records) {
    total = 0;

    for(record in records)
    total += record.data.price

    return total;
    }
    )

    This is in Sencha Touch 2
    Last edited by tbd.work; 18 Jun 2012 at 9:39 AM. Reason: Wanted to specify touch version

Thread Participants: 2

Tags for this Thread

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