Skip to content

Instantly share code, notes, and snippets.

@SPorwal
Forked from MotiurRahman/app.js
Last active August 29, 2015 14:11
Show Gist options
  • Save SPorwal/4cdbf51292811befb2ee to your computer and use it in GitHub Desktop.
Save SPorwal/4cdbf51292811befb2ee to your computer and use it in GitHub Desktop.

Revisions

  1. @mahdirahman mahdirahman revised this gist Apr 15, 2014. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,12 @@
    /*Here has given the sample code to use search functionality of listView. Ti SDK version 3.2.0 and later
    version you can add search capabilities to your list to filter or find items.You can either use ListView's
    searchView property to add a search bar to your list or you can pass your search query to ListView's searchText property
    searchView property to add a search bar to your list or you can pass your search query to ListView's
    searchText property.
    To use the searchView property, create a Titanium.UI.SearchBar object and set it to the ListView's searchView property. Then,
    you need to add the searchableText property to each item in your list when you create it to assign it the text to match when searching.
    You can optionally set the caseInsensitiveSearch property to false to enable case sensitive searches and set the keepSectionsInSearch
    To use the searchView property, create a Titanium.UI.SearchBar object and set it to the ListView's
    searchView property.Then,you need to add the searchableText property to each item in your list when
    you create it to assign it the text to match when searching.You can optionally set the caseInsensitiveSearch
    property to false to enable case sensitive searches and set the keepSectionsInSearch
    to true to preserve section labels while searching.
    For the Android platform, you can also use a Titanium.UI.Android.SearchView object rather than a SearchBar.
  2. @mahdirahman mahdirahman revised this gist Apr 15, 2014. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion app.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,14 @@
    /*Here has given the sample code to use search functionality of listView.
    /*Here has given the sample code to use search functionality of listView. Ti SDK version 3.2.0 and later
    version you can add search capabilities to your list to filter or find items.You can either use ListView's
    searchView property to add a search bar to your list or you can pass your search query to ListView's searchText property
    To use the searchView property, create a Titanium.UI.SearchBar object and set it to the ListView's searchView property. Then,
    you need to add the searchableText property to each item in your list when you create it to assign it the text to match when searching.
    You can optionally set the caseInsensitiveSearch property to false to enable case sensitive searches and set the keepSectionsInSearch
    to true to preserve section labels while searching.
    For the Android platform, you can also use a Titanium.UI.Android.SearchView object rather than a SearchBar.
    The example below creates a list of fruits that can be searched with the search bar at the top of the list.
    Testing Environment:
    Titanium SDK: 3.2.2,
  3. @mahdirahman mahdirahman revised this gist Apr 15, 2014. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,16 @@
    /*Here has given the sample code to use search functionality of listView.
    Testing Environment:
    Titanium SDK: 3.2.2,
    Titanium Studio: 3.2.1
    CLI Version: 3.2.1
    Android,iOS
    Steps to Reproduce:
    1. Create a classic project.
    2. Paste this code in app.js file,
    3. Run this code with testing environment*/

    var win = Ti.UI.createWindow({
    backgroundColor : 'white',
    fullscreen : true
  4. @mahdirahman mahdirahman created this gist Apr 15, 2014.
    43 changes: 43 additions & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    var win = Ti.UI.createWindow({
    backgroundColor : 'white',
    fullscreen : true
    });

    var search = Titanium.UI.createSearchBar({
    barColor : '#000',
    showCancel : true,
    height : 43,
    top : 0,
    });
    search.addEventListener('cancel', function() {
    search.blur();
    });
    // for textSearch, use the change event to update the search value
    // search.addEventListener('change', function(e){
    // listView.searchText = e.value;
    // });

    var listView = Ti.UI.createListView({
    searchView : search,
    caseInsensitiveSearch : true,
    backgroundColor:'#000'
    });
    // for textSearch, add the search bar or text field as a header view
    // var listView = Ti.UI.createListView({headerView: search, caseInsensitiveSearch: true});

    var listSection = Ti.UI.createListSection();
    var fruits = ['Papaya', 'Peach', 'Pear', 'Persimmon', 'Pineapple', 'Pluot', 'Pomegranate'];
    var data = [];
    for (var i = 0; i < fruits.length; i++) {
    data.push({
    properties : {
    title : fruits[i],
    searchableText : fruits[i]
    }
    });
    }
    listSection.setItems(data);

    listView.sections = [listSection];
    win.add(listView);
    win.open();