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

fix(android): fix noresults event in ListView with custom query #14034

Merged
merged 2 commits into from
May 27, 2024

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented May 15, 2024

When using a custom Ti.UI.Textfield for a search view the noresults event is not fired.
The issue is that it is just checking for filterQuery which is not set when you use listView.searchText = "". This PR will set that value which makes the noeresults event fire again.

var win = Ti.UI.createWindow({layout: "vertical"});
var searchView = Ti.UI.Android.createSearchView();

var txtSearch = Ti.UI.createTextField({
	left: '80dp',
	right: '55dp',
	top: 0,
	backgroundColor: 'red',
	borderStyle: Titanium.UI.INPUT_BORDERSTYLE_NONE,
	height: '40dp', //my change
	hintText: "Search from drinks",
	borderStyle: Titanium.UI.INPUT_BORDERSTYLE_NONE,
	returnKeyType: Titanium.UI.RETURNKEY_SEARCH,
	id: "txtSearch"
});

win.add(txtSearch);

var listView = Ti.UI.createListView({});
listView.addEventListener("noresults", function() {
	console.log("no results")
})
txtSearch.addEventListener('change', function(e) {
	listView.searchText = e.value.toLowerCase();
});
var sections = [];
var fruitDataSet = [{	properties: {searchableText: "foo",title: 'Apple'}}, {properties: {searchableText: "foo",title: 'Banana'}}];
var fruitSection = Ti.UI.createListSection({headerTitle: 'Fruits',items: fruitDataSet});
sections.push(fruitSection);
var vegDataSet = [{properties: {searchableText: "foo",title: 'Carrots'}}, {properties: {searchableText: "foo",title: 'Potatoes'}}];
var vegSection = Ti.UI.createListSection({headerTitle: 'Vegetables',items: vegDataSet});
sections.push(vegSection);
listView.sections = sections;
var fishDataSet = [{properties: {searchableText: "foo",title: 'Cod'}}, {properties: {searchableText: "foo",title: 'Haddock'}}];
var fishSection = Ti.UI.createListSection({headerTitle: 'Fish',	items: fishDataSet});
listView.appendSection(fishSection);
win.add(listView);
win.open();

@m1ga m1ga changed the title fix(android): fix noresults event in ListView width custom query fix(android): fix noresults event in ListView with custom query May 15, 2024
@m1ga m1ga added the bug label May 23, 2024
@hansemannn hansemannn merged commit 7e9b52c into master May 27, 2024
7 checks passed
@m1ga m1ga deleted the andoridSearchQuery branch May 27, 2024 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants