1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    0
    flyingace is on a distinguished road

      0  

    Default Answered: Where should a new XTemplate be defined?

    Answered: Where should a new XTemplate be defined?


    I am building my first app with ST2 and began by building the app outlined in Getting Started with Sencha Touch 2 and then taking that and trying to modify it so it met my own needs. The demo app has a DataView List where each element can be tapped to reveal a corresponding detail page.

    In that app the content on the detail pages is being pulled in dynamically and does not need to be styled or arranged much. However, for my own detail pages I need to use a Template or XTemplate to style and position my data.

    I can't seem to figure out where I should define the template (ie, var myTpl = new Ext.XTemplate(...)) —In the controller, in the model?

    Any guidance on this front would be much appreciated.

  2. you can define it in the view

    Code:
    {
      xtype: 'container',
      tpl: new Ext.XTemplate(...)
      ...
    }
    and in you controller you can set the data for the view

    Code:
    view.setData(record.data)
    for example

  3. #2
    Sencha - Training Team mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    690
    Answers
    21
    Vote Rating
    12
    mrsunshine will become famous soon enough

      0  

    Default


    you can define it in the view

    Code:
    {
      xtype: 'container',
      tpl: new Ext.XTemplate(...)
      ...
    }
    and in you controller you can set the data for the view

    Code:
    view.setData(record.data)
    for example

  4. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    0
    flyingace is on a distinguished road

      0  

    Default


    Thanks for your quick reply!

    I get that I can define the XTemplate directly after tpl:, but I would like to be able to do is to define it as a separate object, so that I can then do tpl : xTemplateName. Do you happen to have any thoughts on this?

  5. #4
    Sencha - Training Team mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    690
    Answers
    21
    Vote Rating
    12
    mrsunshine will become famous soon enough

      0  

    Default


    you could also have a template object which manage (singelton manager obeject) your templates and
    than just call Config.getTemplateXyz();

  6. #5
    Sencha Premium Member
    Join Date
    Nov 2011
    Posts
    162
    Answers
    7
    Vote Rating
    2
    UbuntuPenguin is on a distinguished road

      0  

    Default


    Personally, I define my templates in their own classes. When I want to reference them in the view, I do something like so.

    Code:
        config:{
            align:'start',
            tpl:Ext.create('MyApp.view.templates.BiscuitTemplate')
        },
    I don't know of too many reasons why a controller would have to know about the existence of a template unless you had some funky template changing going on.

Thread Participants: 2

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