简体   繁体   English

如何在Titanium PickerRow中添加自定义属性?

[英]How to add custom property in Titanium PickerRow?

Is this possible to add custom property in Titanium.UI.PickerRow? 是否可以在Titanium.UI.PickerRow中添加自定义属性?

In code below, I want to add custom property "index" (using applyProperties PickerRow method) 在下面的代码中,我想添加自定义属性“ index”(使用applyProperties PickerRow方法)

var daysRows = [];
for (var i = 0, j = days.length; i < j; i++) {
    var currentRow = Ti.UI.createPickerRow({
                    title : days[i],

    });

           //adding custom property to identify selection
    currentRow.applyProperties({index:i});

    daysRows.push(currentRow);
};

But when iterating through that PickerRow object later, I could not get custom property index. 但是,当稍后遍历该PickerRow对象时,我无法获得自定义属性索引。 What I am seeing is only Titanium properties title. 我看到的只是钛属性标题。

I am using code below to iterate available properties. 我正在使用下面的代码来迭代可用的属性。

button.addEventListener('click', function(e) {
          ..............
        var selectedRow = picker.getSelectedRow(2);

            for (var k in selectedRow) {
            Ti.API.info('key is: ' + k + ', value is: ' + selectedRow[k]);      
        }
    });

What am I doing wrong? 我究竟做错了什么? Is there any way I can add custom property in PickerRow? 有什么方法可以在PickerRow中添加自定义属性?

This is Titanium/Appcelerator issue in Android platform. 这是Android平台中的Titanium / Appcelerator问题

This issue seen in Titanium SDK 3.1.1 and not fixed in 3.1.2 August 2013 release. Titanium SDK 3.1.1中出现了此问题,2013年8月发行的3.1.2中未解决。

Update 更新

jira.appcelerator.org/browse/TIMOB-14285 is now closed. jira.appcelerator.org/browse/TIMOB-14285现在关闭。 This operation should work Release 6.1.0 onwards. 此操作应从6.1.0版开始运行。

This is old, but I am having similar issues. 这是旧的,但我遇到类似的问题。 What I found as a workaround was to pass in the properties on creation rather than applying 我发现一种解决方法是在创建时传递属性,而不是应用

Ti.UI.createPickerRow({title: 'My Row', customId: 1});

This may not suit everybody, but worked for me 这可能不适合每个人,但为我工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM