Dashcode - 价值转换器的乐趣
我正在创建一个 Dashcode 应用程序,用于显示赢得一项或多项奖项的产品。
数据源对于产品可能赢得的每个奖项都有一个列/字段(产品可能赢得多个奖项)。如果他们赢得了该奖项,则该列为“Y”;如果没有,则该列为空。
因此,我将数据源中的列绑定到图像对象,然后使用值转换器为图像设置正确的 src(如果他们赢得了奖项)。这工作得很好并且只需要很少的代码。就像这样:
myHasGoldAward = Class.create(DC.ValueTransformer,{
transformedValue: function(value){
if (value == 'Y') {
value = "Images/GoldAward.png";
}
return value;
}
问题是我绑定的列仅指示他们是否赢得了特定级别的奖项(即金、银、铜),但还有另一列指示产品类型(即书籍、玩具、音频、视频)。每种不同类型的产品的奖项标志都不同。金图书奖看起来与金玩具奖不同。
我需要能够从我的值转换器中访问其他列,以便能够为奖项设置正确的图像。
有谁知道从值转换器内部访问数据源中另一列的语法?
谢谢!
I'm creating a Dashcode App that displays products that have won one or more awards.
The Data Source has a column/field for each award that the product may win (products may win multiple awards). The column has 'Y' if they won that award and is null if they didn't.
So I'm binding the column from the data source to an image object and then using a Value Transformer to set the correct src for the image if they won the award. This works fine and very little code is required. Just something like this:
myHasGoldAward = Class.create(DC.ValueTransformer,{
transformedValue: function(value){
if (value == 'Y') {
value = "Images/GoldAward.png";
}
return value;
}
The wrinkle is that the column I'm binding to only indicates if they won a certain level award (ie. Gold, Silver, Bronze), but there's another column that indicates the type of product (ie. Book, Toy, Audio, Video). The logo for the award is different for each of the different types of products. The Gold Book award looks different than the Gold Toy award.
I need to be able to access the other column from within my Value Transformer in order to be able to set the right image for the Award.
Does anyone know the syntax to access another column in a data source from inside a value transformer?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论