titanium listView dynamic data binding -
sdk: 3.5.1
i'm not familiar listview mechanics. i'm trying understand how apply json data values item template's bound properties.
i start mapping data
//example var data = ({data:json-data, index:'label'}); var _data = _.map(data, function(item, index) { return { properties: { categorylabel: index, data: item } } }); i want bind list
$.activitydetailslist.sections[0].setitems(_data);
in view have
<listview defaultitemtemplate="activitydetailslistitemtemplate" id="activitydetailslist"> <templates> <itemtemplate name="activitydetailslistitemtemplate"> <label bindid="categorylabel" class="rowtitle" id="categorylabel"/> <view bindid="rightspacer" id="rightspacer"> <imageview bindid="arrowimage" id="arrowimage"/> </view> </itemtemplate> </templates> <listsection id="activitydetailslistsection"> <listitem template='activitydetailslistitemtemplate'/> </listsection> </listview> when iterate through 5 elements, blank rows corresponding arrows.
here's question: how categorylabel text values display? have define in template? part isn't clear me. thought binding data template enough. apparently not.
what worked me:
view xml
<alloy> <window class="container"> <listview defaultitemtemplate="dailyactivitiestemplate" id="activitylist" top="30"> <templates> <itemtemplate name="dailyactivitiestemplate"> <view id="dailyactivities"> <view class="row" id="fundrow"> <label class="rowtitle" id="fund" text="fund: "/> <label bindid="fund" class="rowvalue" id="fund"/> </view> <view class="row" id="amountrow"> <label class="rowtitle" id="amount" text="amount: "/> <label bindid="amount" class="rowvalue" id="amount"/> </view> <view class="row" id="unitsrow"> <label class="rowtitle" id="units" text="units: "/> <label bindid="units" class="rowvalue" id="units"/> </view> <view class="row" id="sourcerow"> <label class="rowtitle" id="source" text="source: "/> <label bindid="source" class="rowvalue" id="source"/> </view> <view class="row" id="unitvaluerow"> <label class="rowtitle" id="unitvalue" text="unit value: "/> <label bindid="unitvalue" class="rowvalue" id="unitvalue"/> </view> </view> </itemtemplate> </templates> <listsection> <listitem template="dailyactivitiestemplate"/> </listsection> </listview> </window> </alloy> controller:
var items = []; _.map(_.first(activities), function(element, key) { if (moment(new date(key)).isvalid()) { _.each(element, function(item, key) { items.push({ fund: { text: item.fund }, amount: { text: item.amount }, units: { text: item.units }, source: { text: item.source }, unitvalue: { text: item.unitvalue } }); }); } }); $.activitylist.sections[0].setitems(items); the important point me didn't need properties:{} parent. confused me. had data in view, needed style tss file.

Comments
Post a Comment