Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(all): fixed rows in filtered results #13684

Merged
merged 7 commits into from
May 3, 2023
Merged

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Dec 20, 2022

This PR adds the option (filterAlwaysInclude) to always show specific rows in your search/filter results, even if they don't match the query

Example:

  • run the code
  • search for "apple"
  • the "apple" row will show up and the "always show..." rows
var win = Ti.UI.createWindow();

var sectionFruit = Ti.UI.createTableViewSection({ headerTitle: 'Fruit' });
sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Apples' }));
sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Bananas' }));
sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Always show (fruits)', filterAlwaysInclude: true}));

var sectionVeg = Ti.UI.createTableViewSection({ headerTitle: 'Vegetables' });
sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Carrots' }));
sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Potatoes' }));
sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Always show (vegetables)', filterAlwaysInclude: true}));

var sectionFish = Ti.UI.createTableViewSection({ headerTitle: 'Fish' });
sectionFish.add(Ti.UI.createTableViewRow({ title: 'Cod' }));
sectionFish.add(Ti.UI.createTableViewRow({ title: 'Haddock' }));
sectionFish.add(Ti.UI.createTableViewRow({ title: 'Always show (fish)' , filterAlwaysInclude: true}));

var table = Ti.UI.createTableView({data: [sectionFruit, sectionVeg, sectionFish], search: Ti.UI.createSearchBar(), height: "45%", top: 0});
win.add(table);

// listview
var listView = Ti.UI.createListView({bottom: 0, height: "45%", searchView: Ti.UI.createSearchBar()});
var sections = [];

var fruitDataSet = [{properties: { title: 'Apple', searchableText:'Apple'}}, {properties: { title: 'Banana', searchableText:'Banana'}}, {properties: { title: 'Always show (fruits)', filterAlwaysInclude:true}}];
var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits', items: fruitDataSet});
sections.push(fruitSection);

var vegDataSet = [{properties: { title: 'Carrots', searchableText:'Carrots'}},{properties: { title: 'Potatoes', searchableText:'Potatoes'}}, {properties: { title: 'Always show (vegetables)', filterAlwaysInclude:true}}];
var vegSection = Ti.UI.createListSection({ headerTitle: 'Vegetables', items: vegDataSet});
sections.push(vegSection);

var fishDataSet = [ {properties: { title: 'Cod', searchableText:'Cod'}}, {properties: { title: 'Haddock', searchableText:'Haddock'}}, {properties: { title: 'Always show (fish)', filterAlwaysInclude:true}}];
var fishSection = Ti.UI.createListSection({ headerTitle: 'Fish', items: fishDataSet});
sections.push(fishSection);

listView.sections = sections;
win.add(listView);

win.open();

Screenshot_20221220-115342 Screenshot_20221220-115329

TODO:

  • Android TableView
  • Android ListView
  • iOS TableView
  • iOS ListView

@m1ga m1ga changed the title feat(android): fixed rows in filtered results feat(all): fixed rows in filtered results Dec 20, 2022
@m1ga m1ga marked this pull request as ready for review January 2, 2023 11:51
@hansemannn hansemannn merged commit bb23609 into master May 3, 2023
@m1ga m1ga deleted the 221220_tableFilter branch May 3, 2023 20:54
narbs pushed a commit to narbs/titanium_mobile that referenced this pull request Jun 7, 2023
* feat(android): fixed rows in filtered results

* android listview

* ios tableview

* listview ios

* chore: update docs

---------

Co-authored-by: Hans Knöchel <hansemannn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants