0
votes

i just want to know hot to display only last three collections inserted in titanium ?

<View dataCollection="competence" dataFilter="filterFunction" height="Ti.UI.SIZE" layout="vertical" backgroundColor="gray" >
    <Label backgroundColor='red' height="Ti.UI.SIZE" text="{date_debut}"/>
    <Label backgroundColor='white' height="Ti.UI.SIZE" text="{date_fin}"/>
</View>

This display collections by 'ASC' from id order, my aim is only to show Three last elements.

I tried with dataFilter :

function filterFunction(collection){
	// Underscore last method not working	
	return _.last(collection, 3);
	
}

Could you help me please ? thank you.

1

1 Answers

0
votes

Try this

function filterFunction(collection){
    return _.last(collection.models, 3);
}