[TIMOB-24019] Windows: Listitems do not maintain itemindex when filtered
| GitHub Issue | n/a |
| Type | Bug |
| Priority | Critical |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-10-18T17:27:12.000+0000 |
| Affected Version/s | Release 6.0.0 |
| Fix Version/s | Release 6.0.0 |
| Components | Windows |
| Labels | n/a |
| Reporter | Ricardo Ramirez |
| Assignee | Kota Iguchi |
| Created | 2016-10-11T22:45:40.000+0000 |
| Updated | 2016-10-21T22:36:09.000+0000 |
Description
Issue Description
Listitems do not maintain item index on search filter
Steps to reproduce
Download and run the project
Search by number 0-11 (the list should filter down to just that number)
Click on the list item with the number (alert with itemindex should pop up)
Expected: the itemindex matches the item's position in the list
Actual: the itemindex is 0 because the list has been filtered down to one item.
Attachments
[~rramirez] is APPTS the correct project for this ticket?
ok confirmed that this is a bug, started work on it. We needed to keep "original" data and indexes. What I also noticed is that
ListView.sectionsdoes not keep the original data, which is a bug too. But one good thing here is that you can actually get the clicked data content by gettingListView.sections\[e.sectionIndex\].items\[e.itemIndex\]because of that. [~rramirez] Do you think you can workaround it by accessingsectionsandsection.itemsdirectly like below?var win = Ti.UI.createWindow(); var win = Ti.UI.createWindow({ backgroundColor: 'green', layout: 'vertical' }); var searchText = Ti.UI.createTextField({ width: Ti.UI.FILL, height: '10%' }); var listView = Ti.UI.createListView({ width: Ti.UI.FILL, height: '90%', caseInsensitiveSearch: true }); var sections = []; var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits' }); var fruitDataSet = [ { properties: { title: 'Apple', searchableText: 'Apple' } }, { properties: { title: 'Banana', searchableText: 'Banana' } }, ]; fruitSection.setItems(fruitDataSet); sections.push(fruitSection); var vegSection = Ti.UI.createListSection({ headerTitle: 'Vegetables' }); var vegDataSet = [ { properties: { title: 'Carrots', searchableText: 'Carrots' } }, { properties: { title: 'Potatoes', searchableText: 'Potatoes' } }, ]; vegSection.setItems(vegDataSet); sections.push(vegSection); listView.sections = sections; searchText.addEventListener('change', function () { listView.searchText = searchText.value; }); listView.addEventListener('itemclick', function (evt) { var clickItemIndex = evt.itemIndex; var clickSectionIndex = evt.sectionIndex; alert(listView.sections[clickSectionIndex].items[clickItemIndex].properties.title); }); win.add(searchText); win.add(listView); win.open();https://github.com/appcelerator/titanium_mobile_windows/pull/881
This should be on 6_0_X now. Check out
6.0.0.v20161021034759.appc ti sdk install --branch 6_0_X 6.0.0.v20161021034759Verified using: OS: Microsoft Windows 10 Pro 10.0.14393 Appc core: 6.0.0-63 Appc NPM: 4.2.8-9 Ti SDK: 6.0.0.v20161021034759 Lumia 550 10.0 e.itemIndex now corresponds to the values in the original listview and not the filtered listview. Provided test case now works as expected Closing ticket