Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24019] Windows: Listitems do not maintain itemindex when filtered

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-10-18T17:27:12.000+0000
Affected Version/sRelease 6.0.0
Fix Version/sRelease 6.0.0
ComponentsWindows
Labelsn/a
Reporter Ricardo Ramirez
AssigneeKota Iguchi
Created2016-10-11T22:45:40.000+0000
Updated2016-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

FileDateSize
listSearchCase (1).zip2016-10-11T22:45:38.000+000010483730

Comments

  1. Patrick Clark 2016-10-11

    [~rramirez] is APPTS the correct project for this ticket?
  2. Kota Iguchi 2016-10-13

    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.sections does 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 getting ListView.sections\[e.sectionIndex\].items\[e.itemIndex\] because of that. [~rramirez] Do you think you can workaround it by accessing sections and section.items directly 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();
       
  3. Kota Iguchi 2016-10-18

    https://github.com/appcelerator/titanium_mobile_windows/pull/881
  4. Kota Iguchi 2016-10-21

    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.v20161021034759
       
  5. Ewan Harris 2016-10-21

    Verified 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

JSON Source