Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

sort json response on click and display accordingly in titanium

$
0
0

Hi I have json response which looks like this.

{
"id": "7",
"issue_title": "Apr - May 2015",
"issue_no": "Issue 1.4",
"cover_image_url": "http://www.link.org/apr--may-2015-7.jpg",
"synopsis_pdf_url": "",
"advertisers_pdf_url": "",
"issue_date": "01-04-2015",
"issue_year": "2015" 
},
{
"id": "3",
"issue_title": "Feb-Mar 2015",
"issue_no": "Issue 1.3",
"cover_image_url": "http://www.link.org/febmar-2015-3.jpg",
"synopsis_pdf_url": "http://www.link.org/febmar-2015-3.pdf",
"advertisers_pdf_url": "http://www.link.org/febmar-2015-3.pdf",
"issue_date": "01-02-2015",
"issue_year": "2015"
},
{
"id": "2",
"issue_title": "Dec 2014 - Jan 2015",
"issue_no": "Issue 1.2",
"cover_image_url": "http://www.link.org/dec-2014--jan-2015-2.jpg",
"synopsis_pdf_url": "",
"advertisers_pdf_url": "",
"issue_date": "01-12-2014",
"issue_year": "2014"
},
{
"id": "1",
"issue_title": "Oct - Nov 2014",
"issue_no": "Issue 1.1",
"cover_image_url": "http://www.link.org/oct--nov-2014-1.jpg",
"synopsis_pdf_url": "",
"advertisers_pdf_url": "",
"issue_date": "01-10-2014",
"issue_year": "2014"
}
Then I retrieved "issue_year" of each element and displayed in picker with multiple occurrence deleted.

Basically when the window loads all the elements are displayed but after that on a click of picker element (i.e 2014 ,2015 ) the elements should get display.

Tableview is used for displaying elements so on each click the array passed to tableview should get change according to year selected from picker.

var i,
len = singleData.length,
sorted = [],
obj = {};
 
for ( i = 0; i < len; i++) {
obj[singleData[i]] = 0;
}
for (i in obj) {
sorted.push(i);
}
 
for (var i = 0; i < sorted.length; i++) {
    data[i] = Ti.UI.createPickerRow({
    title : sorted[i]
}); 
}
 
$.picker.add(data);
 
$.picker.addEventListener('change',function(e){
//what will be the code here
});
Can anyone help on this?

Thanks in advance :-)


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>