My project is to list products with a views, then when click on a product i have to go to another page and re-list the products with scrollableview and target the clicked view to be displayed first (sorry for bad english):
Let's say this is my list (Grabbed from a collection) :
<Alloy>
<Window id="products" onClose="cleanup" title="All products" class="container" >
<ScrollView dataCollection="list_products" dataTransform="parse_liste" layout='vertical' id="results" class="resultats">
<View product_id="{ID}"
product_photo="{photo}"
product_name="{product_name}" lauyout='horizontal' class='heightAuto' width='Ti.UI.FILL' backgroundColor='#eee' bottom='1'>
<ImageView touchEnabled="false" left='10' image='{photo}' />
<View touchEnabled="false" layout='vertical' height='Ti.UI.SIZE'>
<Label touchEnabled="false" left='100' class='nom' text='{product_name}' />
<Label touchEnabled="false" left='100' class='nom' text='{product_price} €/h' />
</View>
</View>
</ScrollView>
<ActivityIndicator color="white" id="activityIndicator" message="Chargement des candidats ..."/>
</Window>
When click on product (the controller) :
var products = Alloy.Collections.liste_recherche;
$.activityIndicator.show();
products.fetch({
success:function(model,results){
Alloy.Globals.results = results;
$.activityIndicator.hide();
}
});
//// CLICK ON A PRODUCT
$.list_products.addEventListener('click', function(e){
if( Alloy.Globals.results ){
///////// GO TO PRODUCT PAGE AND PASS ARGS
var xpng = require('xpng');
xpng.openWin(Alloy.CFG.nav, 'product', Alloy.Globals.products);
}
});
The product page :
var args = $.args;
function getProfil(){
var products_array = [];
var c = ['gray','green','blue','red'];
_.each(args, function(item, key, value){
/* Créer la vue */
var product_container = Ti.UI.createView({
id:item.ID,
layout:'vertical',
backgroundColor:c[Math.floor(Math.random() * c.length)]
});
var product_image = Ti.UI.createImageView({ image : item.photo});
var product_name = Ti.UI.createLabel({
text: item.champs_candidat.nom
});
product_container.add(product_image);
product_container.add(product_name);
products_array.push(product_container);
});
var style = $.createStyle({
classes: ['listeProfiles'],
apiName: 'ScrollableView'
});
var product_scroller = Ti.UI.createScrollableView({
className: 'listeProfiles',
views : products_array,
showPagingControl:true
});
product_scroller.applyProperties(style);
$.product_win.add(product_scroller);
}
Those codes works fine, just i want to display clicked view (from page A) first.
Thank you for help.