Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #11
    Sencha User
    Join Date
    Feb 2008
    Location
    Italy
    Posts
    20
    Vote Rating
    0
    BrightSoul is on a distinguished road

      0  

    Default


    Quote Originally Posted by wellsbr01 View Post
    The template is working, APART from the insertion of the panel.
    Oops, you're right, I made a mistake. Replace this line:
    Code:
    wrapperId += initialConfig.id;
    with this line.
    Code:
    wrapperId += initConfig.id;
    It should work then. Or, you could use the new version of the override. It's posted below.
    You see, once I was able to add components in a template, I wanted to add a whole form and all its child fields. It was doable with the previous override but the instruction would have been incredibly long since it's limited to be one-line. Now, I can also do the following:

    Code:
    {[ this.addCmp({id:"myform", xtype:"formpanel" }) ]}
    {[ this.addCmpTo("myform", {xtype:"textfield", label:"First Name"}) ]}
    {[ this.addCmpTo("myform", {xtype:"textfield", label:"Last Name"}) ]}
    Basically, I added a new method addCmpTo(parentComponentId, initConfigObject) which makes it easier to append children to a previously added component. Here's the new override.

    Code:
    (function () {
        var originalOverwrite = Ext.XTemplate.prototype.overwrite;
    
        Ext.override(Ext.XTemplate, {
            overwrite: function () {
                //execute the base overwrite method
                originalOverwrite.apply(this, arguments);
    
                //then, render any components that addCmp might have added
                while (this.templateComponents.length > 0) {
                    var el = this.templateComponents.shift();
                    if (Ext.get(el.renderTo) != null) {
                        var newel = new Ext.create(el);
                    }
                }
            },
    
            //an array to store the initialconfigs of the components-to-be
            templateComponents:[],
            templateIdCount:0,
    
            //Pushes an initialConfig to the array so that
            //a component can be later created and rendered.
            //It also generates a div container for the component 
            //with a random id if no id was provided
            addCmp: function (initConfig) {
                var wrapperId = "ext-comp-wrapper-";
                if (initConfig.id != void (0)) {
                    wrapperId += initConfig.id;
                } else {
                    //wrapperId += Math.random().toString().replace(".", "");
                    wrapperId += (this.templateIdCount++).toString() + Math.random().toString().replace(".", "");
                }
                initConfig.renderTo = wrapperId;
                this.templateComponents.push(initConfig);
                //return '<div id="' + wrapperId + '"' + (initConfig.width == void(0) ? '' : ' style="width:'+ initConfig.width +'px"') + '></div>';
                return '<div id="' + wrapperId + '" class="y-wrapper"></div>';
            },
    
            addCmpTo: function (container, initConfig, collection) {
    
                if (collection == void(0)){
                    this.addCmpTo(container, initConfig, this.templateComponents);
                } else {
                    if (collection.length > 0){
                        for (var i=0; i<collection.length; i++){
                            if (collection[i].id == container){
                                if (collection[i].items == void(0)){
                                    collection[i].items = [];
                                }
                                collection[i].items.push(initConfig);
                                break;
                            }
                            if (collection[i].items != void(0)){
                                this.addCmpTo(container, initConfig, collection[i].items);
                            }
                        } 
                    }
                }
    
                return;
            }
        });
    })();

  2. #12
    Sencha User
    Join Date
    Feb 2008
    Location
    Italy
    Posts
    20
    Vote Rating
    0
    BrightSoul is on a distinguished road

      0  

    Default


    Quote Originally Posted by abierbaum View Post
    if there was a way to get a scope into the template so I could add handlers that point at specific callbacks on other objects. Does anyone know a good way to get a scope into the template evaluation. (in particular when used with an Ext.List).
    mmh, can you please provide an example with code?

  3. #13
    Sencha User
    Join Date
    Nov 2010
    Posts
    385
    Vote Rating
    4
    gkatz is on a distinguished road

      0  

    Default


    is something similar going to be included in future sencha touch releases?
    seems like a much needed capability...
    can someone from the sencha team comment?
    thanks

  4. #14
    Ext JS Premium Member
    Join Date
    Feb 2009
    Posts
    16
    Vote Rating
    0
    AlexKorn is an unknown quantity at this point

      0  

    Default


    Quote Originally Posted by abierbaum View Post
    The only issue I am running into is that it would be much more powerful if there was a way to get a scope into the template so I could add handlers that point at specific callbacks on other objects. Does anyone know a good way to get a scope into the template evaluation. (in particular when used with an Ext.List).
    This is a bit dirty (at least in terms of abusing Templates), but you can use a closure for this:

    Code:
    (function() {
        // capture scope
        var me = this;
        var container = new Ext.Container({
            tpl: new Ext.XTemplate(
                '<div>',
                    '{[ this.addCmp({xtype:"button", text: "Fire", handler: this.fire }) ]}',
                '</div>',
                {
                    fireEvent: function() {
                        // use scope
                        me.fireEvent('eventName');
                    }
                }
            )
        });
    })();
    BrightSoul, as others have said, this extension is awesome.
    Last edited by AlexKorn; 8 May 2011 at 5:37 PM. Reason: Hadn't finished post. "Preview" will actually do the post if you need to log in again.

  5. #15
    Touch Premium Member
    Join Date
    Jan 2011
    Posts
    37
    Vote Rating
    0
    colworx is on a distinguished road

      0  

    Default


    I'd like to use tpl variables inside my added component. Has anyone done this?
    Code:
      '{[ this.addCmp({xtype:"button", text: "{text}", handler: this.fire }) ]}',

    The above code renders this HTML:
    HTML Code:
    <span class="x-button-label" id="ext-gen1136">',(values['text'] === undefined ? '' : values['text']),'</span>

  6. #16
    Touch Premium Member
    Join Date
    Jan 2011
    Posts
    37
    Vote Rating
    0
    colworx is on a distinguished road

      0  

    Default


    Quote Originally Posted by colworx View Post
    I'd like to use tpl variables inside my added component. Has anyone done this?
    Code:
      '{[ this.addCmp({xtype:"button", text: "{text}", handler: this.fire }) ]}',

    The above code renders this HTML:
    HTML Code:
    <span class="x-button-label" id="ext-gen1136">',(values['text'] === undefined ? '' : values['text']),'</span>
    Oh duh... I just use the values variable like this.. documented in the XTemplate docs.
    Code:
     '{[ this.addCmp({xtype:"button", text: values.prompt, handler: this.fire }) ]}',

  7. #17
    Sencha User
    Join Date
    Sep 2011
    Posts
    16
    Vote Rating
    0
    ForAllThat is on a distinguished road

      0  

    Question


    The code works, except.. it keeps adding the button to the first line, and not the line that I want it added to :S

    Here is my template:
    Code:
    new Ext.XTemplate(                    '<div class="memo">',
                        '<div class="memo-type">{[this.GetWarehouseName(values.WarehouseID)]}</div>',
                        '<div class="memo-title">{ArticleName} ({Amount})</div>',
                        '<tpl if="Selected">{ArticleDescription}</tpl>',
                    '</div>',
                        '{[ this.addCmp({id:"removebutton", xtype:"button", cls: "remove_title", width: "30px", height: "30px", border: 0, style: { border: "0px" }, handler: this.fireEvent}) ]}',
                         {
                            GetWarehouseName: function (id) {
                                var whrstore = Ext.StoreMgr.get('Warehouses');
                                var warehouse = whrstore.findRecord('ID', id);
    
    
                                return warehouse.get('WarehouseName');
                            },
                            fireEvent: function () {
                                console.log("FEUERRR!");
                            }
                        }
    Any help with that? Also when I click the button it fires the event 7! times. Is that supposed to happen? ^^

    Edit: One other thing I noticed is that when I change the Selected property of the record, the added button dissapears..

  8. #18
    Sencha User Vital Aaron's Avatar
    Join Date
    Jun 2011
    Posts
    24
    Vote Rating
    0
    Vital Aaron is on a distinguished road

      0  

    Default


    This is a convenient override, but I think one needs to watch out for timing issues with it. I'm displaying my button in a dataview that is redrawn whenever data in the store changes. I've found that the button doesn't always display because the wrapper hasn't been inserted in the DOC before overwrite() executes.

    I put the Ext.create call inside a defer() and it worked.

    Also, I had to add the xtype to the create() arguments as the first parameter. (I don't know why others haven't run into errors with the create() call. Maybe you all are using a different version of Ext than I am? I'm using 4.0 and writing a desktop app, not using Sencha Touch). Also, the 'new' is not necessary in front of the create() call.

    Here's what my create call looks like now:
    Code:
                    var cfg = this.templateComponents.shift();
                    if (Ext.get(cfg.renderTo) != null) {
                        Ext.defer(Ext.create, 1, this, [cfg.xtype, cfg]);
                    }
    where xtype is of the form "Ext.Button"

  9. #19
    Touch Premium Member
    Join Date
    Aug 2010
    Posts
    195
    Vote Rating
    2
    hitman01 is on a distinguished road

      0  

    Default


    This is a great plugin, I use it all the time. However, I constantly have an issue with itemselector since every time I put the button into my list or dataview, the button tap also triggers itemselector. Is there any way to have an exception to itemselector?

  10. #20
    Sencha User
    Join Date
    Apr 2012
    Posts
    103
    Vote Rating
    10
    pepperseb is on a distinguished road

      0  

    Default


    Thanks a lot Vital Aaron, I save a lot of time tkanks to the bit of code you provided.

    I was struggling to implement those features in Touch 2
    Last edited by pepperseb; 18 Apr 2012 at 1:22 AM. Reason: typo

Similar Threads

  1. DataView Template with button
    By tzander in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 10 Apr 2013, 11:23 AM
  2. button rendering problem with own template
    By bernd01 in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 3 Jun 2010, 1:37 PM
  3. Button sprite template
    By deanna in forum Ext 3.x: Help & Discussion
    Replies: 4
    Last Post: 3 Mar 2010, 8:07 AM
  4. Is it possible to insert button into template?
    By atchijov in forum Ext 3.x: Help & Discussion
    Replies: 4
    Last Post: 19 Jul 2009, 1:27 AM
  5. [FIXED][1.1] Little bug in Button Template ?
    By lioledingue in forum Ext GWT: Bugs (1.x)
    Replies: 1
    Last Post: 6 Oct 2008, 2:20 PM

Thread Participants: 14

Tags for this Thread