Working on Titanium-3.1.0 iOS-6
I am loading data into table view dynamically using following function:
function setData() { if(Titanium.Network.networkType == Titanium.Network.NETWORK_NONE){ var dataArray = []; var userid = Titanium.App.Properties.getString("looking_userid"); var db = Ti.Database.open('scorm-db'); db.execute('CREATE TABLE IF NOT EXISTS assign_courses(left_image TEXT, user_id INTEGER, course_id INTEGER, module_id INTEGER,course_name TEXT, module_name TEXT, module_type TEXT ,zip_file TEXT, launch_path TEXT);'); var course_list = db.execute("SELECT DISTINCT course_id,course_name,left_image FROM assign_courses where user_id = '"+userid+"' ORDER BY course_id"); var cnt=0; while (course_list.isValidRow()) { var Course_ID=course_list.fieldByName('course_id'); var Course_Name=course_list.fieldByName('course_name'); var downloadicon=course_list.fieldByName('left_image'); dataArray.push({leftImage:downloadicon,title:'' + Course_Name, backgroundImage:'/images/Black_Black.png',font:{fontSize:16},color:'white'}); course_id[cnt]= Course_ID; course_list.next(); cnt++; } tableview.setData(dataArray); db.close(); } //if close else{ con=1; var dataArray = []; var userid = Titanium.App.Properties.getString("looking_userid"); var xhr = Ti.Network.createHTTPClient(); xhr.open("POST", "http://enyota.org/iphoneapp/course_list.php"); var params = { uid: userid }; xhr.send(params); xhr.onload = function(){ var json = JSON.parse(this.responseText); var json1 = json.course; var pos; for( pos=0; pos < json1.length; pos++) { downloadicon = '/images/App_to_be_downloaded_icon.png'; dataArray.push({leftImage:downloadicon,title:'' + json1[pos].course_name, backgroundImage:'/images/Black_Black.png',font:{fontSize:16},color:'white'}); course_id[pos]= json1[pos].course_id; } tableview.setData(dataArray); }; } //else close };And my tableview is as:
var tableview = Ti.UI.createTableView({ separatorStyle : Titanium.UI.iPhone.TableViewSeparatorStyle.NONE, //separatorColor : 'black', search:searchC, width:Ti.UI.FILL, scrollable:true, backgroundColor:'transparent', selectedBackgroundColor: 'transparent', //backgroundImage:'normal_butt.png', height:Ti.UI.FILL, opacity:1, left:0, top:41 });When I load the setData function in online condition('else' condition in above code), then in tableview left image loaded in exact left position of row. But when I am on offline condition(if condition in above code), then left image loaded nearly at center of row .
Why tableview differenciate data position on different condition. I want the left image on left side in both condition. How it possible? Please suggest any solution for that issue...