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. #1
    Touch Premium Member
    Join Date
    Feb 2009
    Location
    Firenze, Italia
    Posts
    162
    Vote Rating
    0
    stefx is on a distinguished road

      0  

    Default XTemplate and component

    XTemplate and component


    Hi to all, I've a List object with an XTemplate. I try to insert a toggle into a template with this code:

    Code:
    Ext.setup({
        icon: 'icon.png',
        glossOnIcon: false,
        onReady: function(){
            Ext.regModel('tipi', {
                fields: [
    				{name: 'id',  type: 'int'},
    				{name: 'descrizione',   type: 'string'},
    				{name: 'valore',   type: 'int'}				
                ]
            });
    
            var store = new Ext.data.Store({
                autoLoad: true,
                proxy: {
                    url: 'data.json',
                    type: 'ajax',
                    reader: 'json'
                },
                model: 'tipi'
            });
            var tplTipi = new Ext.XTemplate(
    			'<tpl for=".">',
    				'<div class="tipi">',        	    		
    					'<div>{[new Ext.form.Toggle({value: values.valore, label: values.descrizione, renderTo: "toggleElId"}).show().getEl().getHTML()]}</div>',
    				'</div>',
    			'</tpl>',
    			{
    				compiled: true
    			}
    		)
            var demo = new Ext.Panel({
                fullscreen: true,
                scroll: 'vertical',
                items: [{
                    xtype: 'list',
                    id: 'tipilist',
                    tpl: tplTipi,
                    itemSelector: 'div.tipi',
                    singleSelect: true,
                    store: store
                }]
            });
        }
    });
    This is my html page:
    Code:
    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">	
    	<meta http-equiv="Pragma" content="no-cache">
    	<meta name="viewport" content="height=device-height,width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;">
    	<meta name="apple-mobile-web-app-capable" content="yes" />
    
        <title>Temp</title>
    	<link rel="stylesheet" href="ext-touch.css" type="text/css">
    	<script type="text/javascript" src="ext-touch-debug-w-comments.js"></script>    
    	<script type="text/javascript" src="index_temp.js"></script>
        	
    </head>
    <body onorientationchange ="setTimeout(function(){window.scrollTo(0,1)},100);" onload ="setTimeout(function() {window.scrollTo(0,1)},100);">
    <div style="display:none;" id="toggleElId"></div>
    </body>
    </html>
    I try to render a toggle in a invisible div (toggleElId) to get the HTML to insert in a template. with {[new Ext.form.Toggle({value: values.valore, label: values.descrizione, renderTo: "toggleElId"}).show().getEl().getHTML()]} I get the html but I can't see anything in a page. Otherwise, with <div style="display:block;" id="toggleElId"></div> the script return a toggle but two times... so, double toggle...

    Any idea?
    Thanks a lot
    Stefano

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,604
    Vote Rating
    580
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    It's not supported to do it that way. If you really must insert components into the list, then do it after the list has rendered, then you can enumerate over the elements and just render the toggle in there directly.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Touch Premium Member
    Join Date
    Feb 2009
    Location
    Firenze, Italia
    Posts
    162
    Vote Rating
    0
    stefx is on a distinguished road

      0  

    Default


    Ok, thanks.
    stefano

  4. #4
    Ext User
    Join Date
    Aug 2010
    Posts
    12
    Vote Rating
    0
    obusek is on a distinguished road

      0  

    Default


    Quote Originally Posted by evant View Post
    It's not supported to do it that way. If you really must insert components into the list, then do it after the list has rendered, then you can enumerate over the elements and just render the toggle in there directly.
    Would you please provide a sample code snippet of how to do this? Assume we already have a List object created, and we just want to iterate over each row and add a basic Panel. Thank you

  5. #5
    Ext User
    Join Date
    Aug 2010
    Posts
    12
    Vote Rating
    0
    obusek is on a distinguished road

      0  

    Default


    I was thinking something list this:

    Code:
    productsList.items.each(function(item, idx, len) {
        alert("1");
        item.add(new Ext.Button({text:idx}));
    });
    but the alert inside the loop is never shown... productsList is a List that shows up successfully on the screen.

  6. #6
    Sencha User
    Join Date
    Apr 2011
    Posts
    1
    Vote Rating
    0
    dhawalkote is on a distinguished road

      0  

    Default


    For me, it worked like this.
    Add listener for the list.
    Code:
    listeners:{
    		refresh: function(){
    			var list = this;
    			this.store.data.each(function(item, idx, len){ var btn = new Ext.Button({text: 'Btn'}); btn.render(list.all.elements[idx])});
    		}
    	}

Similar Threads

  1. [SOLVED] Using an XTemplate component in a toolBar.
    By FATAL1TY in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 4 Apr 2009, 5:07 AM
  2. DataView + XTemplate + Ext.Component
    By RoL in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 17 Oct 2008, 8:05 AM

Thread Participants: 3

Tags for this Thread