Titanium SDK: 3.1.3 G.A. Platform & version: iOS 6.1 Device: iOS simulator Host OS: OSX 10.8++ Hi guys, i'm developing a cross-platform app with titanium studio.
I have problems with dynamic table view on Android; i can't see data from json in the table view even if are correctly fetched from json.
I have this SEARCH.xml
<Alloy> <Tab id="searchTab" icon="ios_icons/search.png" activeIcon="ios_icons/search_active.png"> <Window id="searchWin" title="Search"> <TextField id="searchText"></TextField> <Button id="searchBar" onClick="searchButton">Search</Button> <Label id="archeologia">Archeologia</Label> <Button id="checkbox_archeologia" value="Archeologia" backgroundImage='ios_icons/checkbox.png'></Button> <Label id="identita">Identità</Label> <Button id="checkbox_identita" value="Identita" backgroundImage='ios_icons/checkbox.png'></Button> <Label id="cultura">Cultura</Label> <Button id="checkbox_cultura" value="Cultura" backgroundImage='ios_icons/checkbox.png'></Button> <TableView id="searchTableView" filterAttribute="title" onClick="showItems" itemImage=""> </TableView> </Window> </Tab> </Alloy>
SEARCH.JS
var rowID = 0; search(rowID); function search(rowID){ var collection; if(rowID == "4"){ collection = Alloy.createCollection("circuiti_archeologia"); }else if(rowID == "28"){ collection = Alloy.createCollection("circuiti_cultura"); }else if(rowID == "27"){ collection = Alloy.createCollection("circuiti_identita"); }else if(rowID == 0){ collection = Alloy.createCollection("circuiti"); } collection.fetch({ success : function(){ var id, name, description, siti, name_length, description_length, image ,row, rootId, rightImage, nameColor, top; var rowData = []; rootId = rowID; _.each(collection.models, function(element, index, list){ id = element.attributes.id; name = element.attributes.name; description = element.attributes.description; image = element.attributes.image; siti = element.attributes.siti; // c'è solo nella VISTA CIRCUITI description_length = description.length; name_length = name.length; if(name_length >= 50 && name_length <70){ top = "35%"; }else if(name_length >= 70){ top = "45%"; }else if (name_length < 70 && description_length !=0){ top = "20%"; }else if(name_length < 70 && description_length == 0){ top = "15%"; } if(rootId == 4){ rightImage = "ios_icons/right-arrow-viola.png"; nameColor = "#782661"; }else if(rootId == 28){ rightImage = 'ios_icons/right-arrow-turchese.png'; nameColor = "#0DA99D"; }else if (rowID == 27){ rightImage = "ios_icons/right-arrow-orange.png"; nameColor = "#F39200"; }else{ rightImage = "ios_icons/right-arrow-viola.png"; nameColor = "#000"; } var payload={ rootId: rootId, rowId: id, itemName: name, itemDesc: description, itemDescTop: top, rightImage: rightImage, itemImage: image, nameColor: nameColor, siti: siti, height: "" }; row=Alloy.createController('row_search',payload).getView(); rowData.push(row); $.searchTableView.data=rowData; }); }, error : function(){ Ti.API.error("hmm - this is not good!"); } }); }ROW_SEARCH.XML
<Alloy> <TableViewRow id="row_search" rowId="1" itemName="Test1" itemDesc="Test1" searchImage="" itemImage="" siti=""> <Label id="itemName">test</Label> <Label id="itemDesc">test</Label> <ImageView id="searchImage" image="ios_icons/right-arrow-viola.png"></ImageView> </TableViewRow> </Alloy>ROW_SEARCH.JS
var args = arguments[0] || {}; $.row_search.rightImage = args.rightImage; $.itemName.color = args.nameColor; $.itemName.text = args.itemName; $.itemDesc.text = args.itemDesc; $.itemDesc.top = args.itemDescTop; $.row_search.itemName = args.itemName; $.row_search.itemDesc = args.itemDesc; $.row_search.itemImage = args.itemImage; $.row_search.siti = args.siti; if(args.height !==""){ $.row_search.height = args.height; }else{ $.row_search.height = "70%"; } if(args.itemImage !== ""){ $.searchImage.image = args.itemImage; }else{ $.searchImage.image = "ios_icons/right-arrow-viola.png"; }
Why "$.searchTableView.data=rowData" doesn't work on Android but work fine on iOS? thanks in advance.