Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20188] iOS: Setting UI.SearchBar.value after tableview creation has no effect.

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionCannot Reproduce
Resolution Date2019-09-20T16:37:51.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsreprod, searchbar
ReporterSrikanth Sombhatla
AssigneeUnknown
Created2016-01-04T05:34:19.000+0000
Updated2019-09-20T16:37:51.000+0000

Description

Setting Titanium.UI.SearchBar value after creating tableview (or listview) is not reflecting in search results. Use the following code
var fruits = [ {title: 'Apples'}, {title: 'Bananas'}, {title: 'Strawberry'}, {title: 'Pineapple'},{title: 'Apples'}, {title: 'Bananas'}, {title: 'Strawberry'}, {title: 'Pineapple'}, {title: 'Apples'}, {title: 'Bananas'}, {title: 'Strawberry'}, {title: 'Pineapple'},{title: 'Apples'}, {title: 'Bananas'}, {title: 'Strawberry'}, {title: 'Pineapple'}, {title: 'Apples'}, {title: 'Bananas'}, {title: 'Strawberry'}, {title: 'Pineapple'},{title: 'Apples'}, {title: 'Bananas'}, {title: 'Strawberry'}, {title: 'Pineapple'}, {title: 'Apples'}, {title: 'Bananas'}, {title: 'Strawberry'}, {title: 'Pineapple'},{title: 'Apples'}, {title: 'Bananas'}, {title: 'Strawberry'}, {title: 'Pineapple'} ];
 
var sampleWindow = Ti.UI.createWindow();
var navWindow = Ti.UI.iOS.createNavigationWindow({
  window: sampleWindow
});
 
var search = Ti.UI.createSearchBar({hintText: "search by name", showCancel: true});
search.addEventListener("return", searchBarReturn);
 
var tableView = Ti.UI.createTableView();
tableView.addEventListener("click", tableClicked);
 
tableView.search = search;
tableView.searchHidden = true;
tableView.filterAttribute = 'customAttr';
 
sampleWindow.add(tableView);
 
fillTableData(fruits);
 
function fillTableData(_data){
  var tempData = [];
  for(var i=0, j=_data.length;i<j;i++){
    var row = Ti.UI.createTableViewRow({
      height: 40,
      backgroundColor: "#fff",
      customAttr: _data[i].title
    });
 
    row.add(Ti.UI.createLabel({
      left:'5%',
      width:'90%',
      height:'100%',
      text: _data[i].title
    }));
 
    tempData.push(row);
  }
  tableView.setData(tempData);
}
 
function tableClicked(){
  Ti.API.warn("table clicked!");
}
 
function searchBarReturn(){
  search.blur();
}
 

navWindow.addEventListener('open', function() {
  search.value = 'App';
});

navWindow.open();
Actual: All items are shown irrespective of setting search string. Expected: Items should be filtered as per search string.

Comments

  1. Lee Morris 2017-06-13

    I am able to reproduce this issue with the following environment; iPhone 7 (10.2) Studio 4.9.0.201705302345 Ti SDK 6.1.1.v20170609091155 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.8.0_131
  2. Alan Hutton 2019-09-20

    Closing. Unable to reproduce the issue. Axway Appcelerator Studio, build: 5.1.4.201909061933  macOS : 10.14.6 Node.js Version : 8.9.1 npm Version : 5.5.1 Appcelerator CLI : 7.1.1 Titanium CLI CLI Version : 5.2.1 node-appc Version : 0.2.49 Titanium SDKs : 8.2.0.GA

JSON Source