私のプロジェクトは、ビューを持つ製品をリストすることです。製品をクリックすると、別のページに移動してスクロール可能なビューの製品を再表示し、クリックされたビューを最初に表示する必要があります)英語悪い:チタンスクロール可能なビューのインデックス
のは、(コレクションから取得)、これは私のリストであるとしましょう:
<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>
すると、製品に対するクリック(コントローラ):
を製品ページ:
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);
}
これらのコードは、ちょうど私が最初に(ページAから)クリックされたビューを表示したい、正常に動作します。
ありがとうございました。
こんにちはのPrashant SAINI、助けてくれてありがとう、私はPRODUCT_IDを得ることができ、私はちょうどデータ収集から今すぐインデックスを取得する方法を疑問に思いますか?私は試しました:\t \t var index = _.findIndex(Alloy.Globals.results、{'product_id':e.source.product_id});それは私にエラーをスローする – user44321
こんにちは、私はテストし、それは働いて、あなたの助けをありがとう。 – user44321
あなたはそれを解決しました。 コレクションのアウトラインを投稿しなかったため、コレクションからインデックスを取得するコードを書くことができませんでした。しかし、私はあなたが私のステップで解決できると思っていました。それは、完全な答えを得ることよりも物事を理解するのに役立ちます(ただし、StackOverFlowは正確な答えを意味します)。 –