- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
// Controller .js
$.tblRow_CurrentRow = [];
var currentList = [
{plan:' Plan1',date:'18 Feb 2014',tier:'one'},
{plan:'Plan2',date:'18 Dec 2013',tier:'two'},
{plan:'Plan3',date:'20 Feb 2014',tier:'three'},
var data = [];
for(var i=0;i < currentList.length ;i++){
if(i%2 == 0){
$.tblRow_CurrentRow[i].backgroundColor = "#FFFFFF";
}
else{
$.tblRow_CurrentRow[i].backgroundColor = "#ABC012";
}
// Set text data to the label
$.lbl_Plan.text = currentList[i].plan;
$.lbl_Date.text = currentList[i].date;
$.lbl_Tier.text = currentList[i].tier;
// Adding label to the TableRow!
$.tblRow_CurrentRow[i].add($.lbl_Plan);
$.tblRow_CurrentRow[i].add($.lbl_Date);
$.tblRow_CurrentRow[i].add($.lbl_Tier);
data.push($.tblRow_CurrentRow[i]);
}
$.tbl_TabeleView.data = data;
// Controller .xml
<TableView id = "tbl_TabeleView" >
<TableViewRow id= "tblRow_CurrentRow">
<Label id = "lbl_Plan"></Label>
<Label id = "lbl_Date"></Label>
<Label id = "lbl_Tier"></Label>
</TableViewRow>
</TableView>
将 dataList 添加到合金钛的 tableviewRow 时出现问题。
错误信息 message = "'undefined' 不是一个对象(正在计算 '$.tblRow_CurrentRow[i].add')";
最佳答案
在您看来,您将 $.tblRow_CurrentRow 定义为单个 TableViewRow。您不能将其视为 Controller 中的对象数组。我修复了您的代码以使其正常工作,因此您可以看到它应该如何:
index.js:
$.tblRow_CurrentRow = [];
var currentList = [
{plan:' Plan1',date:'18 Feb 2014',tier:'one'},
{plan:'Plan2',date:'18 Dec 2013',tier:'two'},
{plan:'Plan3',date:'20 Feb 2014',tier:'three'},
];
var data = [];
for (var i=0; i < currentList.length; i++){
$.tblRow_CurrentRow[i] = $.UI.create('TableViewRow', {
backgroundColor: (i % 2 === 0 ? '#FFFFFF' : '#ABC012'),
layout: 'vertical',
});
// Set text data to the label
$.tblRow_CurrentRow[i].add(
$.UI.create('Label', { text: currentList[i].plan } )
);
$.tblRow_CurrentRow[i].add(
$.UI.create('Label', { text: currentList[i].date } )
);
$.tblRow_CurrentRow[i].add(
$.UI.create('Label', { text: currentList[i].tier } )
);
data.push($.tblRow_CurrentRow[i]);
}
$.tbl_TabeleView.data = data;
$.getView().open();
index.xml:
<Alloy>
<Window>
<TableView id="tbl_TabeleView" />
</Window>
</Alloy>
基本上, View 模板仅包含简单的 Window 和空的 TableView,我们将在其中添加行。在 for 循环中,我创建 TableViewRow 对象,设置不同的背景,然后添加您需要的所有 3 个标签。
垂直布局让我们可以很好地一个接一个地显示标签。
方法 $.UI.create('TableViewRow') 只是 Ti.UI.createTableViewRow(); 的更好版本。如果您感到困惑,您可以替换它们。
关于javascript - 无法将数据列表添加到合金钛的 tableRow 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21852571/
我启动了一个使用sqlite db的Titanium应用程序。我得到奇怪的数据库结果,所以只想使用FF SQLite Manager浏览数据库,但是我不确定数据库在哪里? 这是创建数据库(部分)的代码
我正在使用Titanium SDK的openCamera函数来捕获图像并将其存储到sdcard。 function captureImage() { var capturedImg;
如何在应用程序的全屏播放视频中显示youtube或位?我必须导航到一个特殊链接吗?还是有专门的API可以全屏查看它? 想法是单击“显示视频”链接,然后全屏显示视频,并获得按钮播放纱布并“完成”。单击完
抱歉,如果它看起来像个菜鸟问题,但我是钛的新手,所以有些概念对我来说很陌生。 我有一个名为entry.js的脚本,该脚本是使用require('entry.js')从details.js调用的。 现在
在 appcelerator titanium 中,是否可以在函数调用中设置事件监听器? 有点像 var coolManDool = function(){...}; coolManDool.addE
我使用forwardGeocoder 获取纬度值,并将获得的纬度值与十进制数相加。看看下面的代码。 Ti.Geolocation.forwardGeocoder(textField.value, fu
在我看来,这个问题更接近commonJs,而不是titanium。我编写了一个大文件。相当丑陋(代码的第一次和平)。如果你愿意的话,你可以跳过它。 问题:我的代码中有 2 个 View ,我想将它们放
在 appcelerator titanium 中,是否可以在函数调用中设置事件监听器? 有点像 var coolManDool = function(){...}; coolManDool.addE
我已经为我的应用程序实现了后台服务。我正在使用它来通过使用位置服务来获取用户的当前位置。 我将解释实现此方法的方式-“XYZ.js”-显示用户距离的屏幕。添加了以下代码以设置注册后台服务- var i
我已经设置了相关的证书和应用程序,但是当我为iTunes构建它时,它将始终构建该应用程序的开发版本。我试图通过执行以下操作来更改证书: Titanium iOS设备->管理配置,但无法选择我的生产证书
是否可以在窗口加载后立即显示警报? 我有一个创建窗口语句,然后是一条警告消息,然后返回。 function NewView() { var self = Ti.UI.createWindow(
我想知道是否有一个功能可以在用户退出应用程序时保存上次查看的窗口,这样当他们再次进入应用程序时,它会转到上次查看的页面,而不是重新启动。我看过 Ti.App.Properties,但还没有真正找到我要
我可以在单个 Controller 文件中做到这一点: Ti.Network.addEventListener('change', function(e) { networkIsOnline
我是 Titanium Studio 的初学者。选择按钮时我可以隐藏键盘。它有效, okBtn.addEventListener("click", function(e) { textField.bl
我正在使用 Titan 创建一个适用于 Android 和 iOS 的应用程序,只要服务器运行,它就会每 5 秒向服务器发送一个新的地理位置。然而,在 iOS 上,应用程序会在随机间隔后停止发送这些位
我在 ScrollView 中有两个 View ,它们是使用垂直布局属性放置的。我尝试了多种组合,但两种 View 之间总是存在巨大差距。 var view = Titanium.UI.createS
我可以将其关闭。 代码: //get current Location // Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY
如何在 XML 中制作网格布局。例如说我想要一个 4x4 板。我只需要制作 16 个按钮并使用 jss 格式化它们吗?例如,这就是我所拥有的,但还不是板格式。 square
这是我第一次为 iPhone 开发钛金属模块。我正在为 iPhone 构建 Google Analytics 模块。 如果我要使用 XCode 实现 Google Analytics,我可以使用 di
有没有一种方法可以用 javascript(使用 titanium)计算 PDF 页数?我正在开发一个应用程序,我需要页面数量才能知道用户在哪个页面上。现在我正在对大量页面进行硬编码,但我想通过 ja
我是一名优秀的程序员,十分优秀!