我正在尝试创建我的 json 数据的详细视图。我不确定如何真正接近它。我有事件监听器,但我不确定如何根据所选栏的名称提取数据。这是我的 json 拉取:
var win =Titanium.UI.currentWindow;
var data = [];
var xhr = Titanium.Network.createHTTPClient();
var barList = Titanium.UI.createTableView({
height:366,
width: 320,
top:0,
left:0
});
win.add(barList);
xhr.onload = function () {
var json = JSON.parse(this.responseText);
Ti.API.info(json.length);
for (var i = 0; i < json.length; i++) {
var row = Titanium.UI.createTableViewRow({
hasChild: true,
className: 'bar-row',
filter: json[i].bar.name
});
var titleLabel = Titanium.UI.createLabel({
text: json[i].bar.name,
font: {
fontSize: 14,
fontWeight: 'bold'
},
left: 70,
top: 5,
height: 20,
width: 210
});
row.add(titleLabel);
var addressLabel = Titanium.UI.createLabel({
text: json[i].bar.address,
font: {
fontSize: 10,
fontWeight: 'normal'
},
left: 70,
top: 25,
height: 40,
width: 200
});
row.add(addressLabel);
var iconImage = Titanium.UI.createImageView({
text: json[i].bar.logo_file_name,
width: 50,
height: 50,
left: 10,
top: 10
});
row.add(iconImage);
data.push(row);
row.addEventListener('click',function(e){
var detail = Ti.UI.createWindow({
title: e.rowData.title
});
detail.open({modal: true});
})
}
barList.data = data;
};
xhr.open('GET', 'http://site.com/db.json');
xhr.send();
JSON 数据:我正在寻找所选栏的名称、描述、mon_special、tues_special 等