简体   繁体   中英

How to add custom property in Titanium PickerRow?

Is this possible to add custom property in Titanium.UI.PickerRow?

In code below, I want to add custom property "index" (using applyProperties PickerRow method)

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. 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?

This is Titanium/Appcelerator issue in Android platform.

This issue seen in Titanium SDK 3.1.1 and not fixed in 3.1.2 August 2013 release.

Update

jira.appcelerator.org/browse/TIMOB-14285 is now closed. This operation should work Release 6.1.0 onwards.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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