android - sort json response on click and display accordingly in titanium -


hi have json response looks 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 retrieved "issue_year" of each element , displayed in picker multiple occurrence deleted.

basically when window loads elements displayed after on click of picker element (i.e 2014 ,2015 ) elements should display.

tableview used displaying elements on each click array passed tableview should change according year selected picker.

var i, len = singledata.length, sorted = [], obj = {};  ( = 0; < len; i++) { obj[singledata[i]] = 0; } (i in obj) { sorted.push(i); }  (var = 0; < sorted.length; i++) {     data[i] = ti.ui.createpickerrow({     title : sorted[i] });  }  $.picker.add(data);  $.picker.addeventlistener('change',function(e){ //what code here }); 

can on this?

this simple. here's need do:

add custom property picker, containing obj sent:

for (var = 0; < sorted.length; i++) {     data[i] = ti.ui.createpickerrow({     title : sorted[i],     obj: my_obj // here need pass object sent display });  } 

next, in listener, can access object using:

$.picker.addeventlistener('change',function(e){   alert(e.source.obj); // alert correct object created in picker! }); 

hope helps! -lucas


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -