PDA

View Full Version : display only first tag in list



manish khamar
18 Aug 2011, 12:20 AM
Hello
I parse below json in list.
--------------------trial.json.----------------------------------------------

[
{
"srno":"0",
"terabitzid":"176100012257",
"totalcount":"104",
"category":"P",
"pno":"1",
"sourcename":"",
"address":"Address Not Available",
"city":"Reno",
"state":"NV",
"zip":"89502",
"price":"$1,500,000",
"beds":"0",
"baths":"0",
"sqft":"0",
"broker":"Rustic Realty",
"agentname":"Joseph",
"agentemail":"NA",
"agentphone":"775-356-1222",
"latitude":"39.5284042",
"longitude":"-119.8221971",
"picture":[{"url":"http://img3.terabitz.com/mls/NNRMLS/img/11/000/2696/1.jpg"},
{"url":"http://img3.terabitz.com/mls/NNRMLS/img/11/000/2696/10.jpg"},
{"url":"http://img3.terabitz.com/mls/NNRMLS/img/11/000/2696/11.jpg"}]
}
]

when i parse data in list then it show me all three url in list.
but i want to get only first url ( http://img3.terabitz.com/mls/NNRMLS/img/11/000/2696/1.jpg).
so pls help me to solve it.

code:

Ext.regModel('User', {
fields: ['address','city','state','zip','price','beds','baths','sqft','latitude','longitude'],

hasMany: {model: 'Picture', name: 'picture'},

});


Ext.regModel('Picture', {
fields: ['url'],
});


var c = new Ext.data.Store({
model: 'User',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'trial.json',
reader: {
type: 'json'
}
}
});


var list = new Ext.List({
fullscreen: true,
itemTpl : '<tpl for="."><div class="user"><div>{price}</div><div>{address}</div><div>{city} {state}, {zip}</div><div>{beds} Be | {baths} Ba | {sqft} sqft</div> <tpl for="picture"><div class="pic"><img src="{url}" width="100" height="50" ></div></tpl></div></tpl>',
store : c,
singleSelect : 'div.user'
--------------------
----------------------
---- rest of the code------
----------------------------

slmd
18 Aug 2011, 2:29 AM
Hi!

I would suggest you to simply divide your picture tag in 3 as follow


"picture1":"url":"http://img3.terabitz.com/mls/NNRMLS/img/11/000/2696/1.jpg",
"picture2":"url":"http://img3.terabitz.com/mls/NNRMLS/img/11/000/2696/10.jpg",
"picture3":"url":"http://img3.terabitz.com/mls/NNRMLS/img/11/000/2696/11.jpg"

This way you can use the one you want or all together. It's up you.
Yours

manish khamar
18 Aug 2011, 2:58 AM
thanks for reply ,

I have no rights to change json file and json file can not be changed because this json file is also used for other purpose.

pulponair
18 Aug 2011, 5:05 AM
Hi,

did you try something like
{picture[0].url} or
{picture.0.url}
within your template?

Cheers,
Nikolas

manish khamar
18 Aug 2011, 5:27 AM
thanks for reply ,
Below code is also not working.
{picture[0].url} or
{picture.0.url}

pulponair
18 Aug 2011, 5:49 AM
Hi,

sorry my fault:
{[values.picture[0].url]}

will do the trick.

cheers,
Nikolas

manish khamar
18 Aug 2011, 5:53 AM
thanks for reply,

this is also not working .

But i have found solution of it myself.

pulponair
18 Aug 2011, 5:57 AM
Hey,

it is working. Try yourself:


<script>


Ext.setup({
onReady: function(){
Ext.regModel('listItem', {
fields: ['name', 'items']
});


var store = new Ext.data.Store({
model: 'listItem',
data : [
{name: 'test', items: [
{title: 'a'},
{title: 'b'},
{title: 'a'}
]}
]
});


var list = new Ext.List({
fullscreen: true,
itemTpl: '{name} {[values.items[0].title]}',
store: store
});


list.show();
}
});


</script>

manish khamar
18 Aug 2011, 6:01 AM
thanks ,

it 's working now

manish khamar
18 Aug 2011, 6:07 AM
thanks for help me.

I have two problem more as below:

(1)How I can use Slidetoggle like jquery in sencha touch?

(2)How i can make slideshow for dynamic images or static images?

it search many time but i still not getting any solution .

pls help me as soon as possible .

pls send me reply if u know any answer of above question.