1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    12
    Vote Rating
    0
    Viswa317 is on a distinguished road

      0  

    Default Unanswered: In Ext.dataview.List.. in item tpl displaying every thing in one block

    Unanswered: In Ext.dataview.List.. in item tpl displaying every thing in one block


    This is my model
    -------------------

    Code:
    Ext.define('myApp.model.Wants', {	extend : 'Ext.data.Model',
    	config : {
    
    
    		fields : [
    			{ name : 'id', type : 'int'},
    			{ name : 'replyCount', type : 'int'},
    			{ name : 'text',type : 'string'},
    			{ name : 'time', type : 'string',dateFormat : 'D'}
    		],
    		belongsTo: 'Packet'
    	}
    	
    });
    Code:
    Ext.define('myApp.model.Packet', {	extend : 'Ext.data.Model',
    	config : {
    
    
    		fields : [
    			{ name : 'id', type : 'int'},
    			{ name : 'fullname', type : 'string'},
    			{ name : 'imageURI', type : 'string'},
    			{ name : 'wants', type : 'object'}
    		],
    		hasMany: { 
                model: 'Wants', 
                name: 'wants'
            }
    	}
    	
    });
    This is store
    --------------

    Code:
    Ext.define('myApp.store.WantsStore', {	extend : 'Ext.data.Store',
    	config : {
    		model : 'myApp.model.Packet',
    		proxy : {
    			type : 'ajax',
    			 url : '
    http://127.0.0.1:8080/myapp/message/mwants'
    , reader : { type : 'json', rootProperty : 'packet' } }, sorters : [{ property : 'time', direction : 'DESC' }] } });
    This my List
    --------------
    Code:
    Ext.define('myApp.view.WantsList', {
    	extend : 'Ext.dataview.List',
    	xtype : 'wantslist',
    	config : {
    		itemCls : 'my-dataview-item',
    		loadingText : 'Loading items...',
    		emptyText : '<div class="notes-list-empty-text">No Wants found.</div>',
    		itemTpl : Ext.create('Ext.XTemplate',
    		'{[this.imagedown(values.wants,values.fullname,values.imageURI)]}',{
    			imagedown : function(wants, fullname, imageURI) {
    				var str = '';
    				for ( i = 0; i < wants.length; i++) {
    					str += '<div><img src="'+localStorage.httpServerPrefix+''+imageURI+'"/><span>' + fullname + '</span><span id="count">' + wants[i].replyCount + '</span>'+
    						   '<p>' + wants[i].text + '<span id="time">' + wants[i].time + '</span></p></div><div style="margin-top:10px;"></div>'
    				}
    				return str;
    			}
    		})
    	}
    });
    This is the Json coming from server
    ------------------------------------------

    Code:
    {"class":"co.myapp.json.WsResponse","code":0,"message":"SUCCESS",
    	"packet":
    	{"class":"co.myapp.json.MyWantPacket","fullname":" viswa","imageURI":"","userid":1,"username":"viswa11","wantSuggestion":"learn guitar",
    	"wants":[{
    		"class" : "co.myapp.json.MyWant",
    		"id" : 2,
    		"replyCount" : 0,
    		"text" : "Message 2",
    		"time" : "Oct 3, 2012 - 14:59:02"
    	}, {
    		"class" : "co.myapp.json.MyWant",
    		"id" : 1,
    		"replyCount" : 2,
    		"text" : "Message 1",
    		"time" : "Oct 3, 2012 - 14:59:02"
    	}]
    }}
    The output i got is a block contains all list, i can't select one item in list (i mean one row),

    but what i want is list... LIKE THIS

    image fullname replayCount text time (this is 1 row in a list) image fullname replayCount text time (this is 2 row in a list)image fullname replayCount text time (this is 3 row in a list)image fullname replayCount text time (this is 4 item in a list)

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Answers
    3467
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    First thing I see is you should not be creating instances outside a method. Since your itemTpl is just a config, you need to specify a config (string in this case)
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Dec 2012
    Posts
    1
    Vote Rating
    0
    UkiMiawz is on a distinguished road

      0  

    Default same problem

    same problem


    I'm sorry has someone found the solution for this?
    I'm having the same problem

    I'm using a nested JSON as data and 2 models with HasMany association.
    I tried the tpl tag in the itemTpl

    Code:
    itemTpl: [                      		'<tpl for="Childs">',                
                    		'<div class="list-item">',                       		
                    		'<div class="list-item-title"><h3>{Name}</h3></div>',
                    		'<div class="list-item-description"><h4>{Age}</h4></div>',
                    		'</div></tpl>'
                    	].join(''),
                        store: 'Parents'
    but the childs displayed as one big block
    Last edited by UkiMiawz; 19 Dec 2012 at 4:47 AM. Reason: adding more details

Thread Participants: 2

Tags for this Thread

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..." hd porno faketaxi