[ALOY-1031] Alloy: ListView not binding correctly with Collection when using Encrypted Database Module

GitHub Issuen/a
Resolution Date2014-05-28T17:33:27.000+0000
Affected Version/sAlloy 1.3.1
Fix Version/sAlloy 1.5.0
Labelsqe-manualtest, supportTeam
ReporterMarco Cota
AssigneeTim Poulsen



In iOS when using a custom sync for enabling the Encrypted Database Module as a type for the model and binding the collection to a listView after calling the first fetch the listView get correctly populated, but when trying to call a fetch with a SQL query the listView does not reflect the new data in the collection. After testing using the standard sql type or using the encrypted database in Android everything works as expected.

Steps to repro

1. Run the Sample app attached (encDB.zip) in iOS. 2. Type 3 letter into the search bar. Expected Result: After inserting 3 characters the collection will fetch using a SQL query and the listView will be updated. Actual Result: After inserting 3 characters the collection is fetch using a SQL query but the listView is not updated.




  1. Tim Poulsen 2014-05-28 Here's what I did to get your example app working. *Solution 1* First, I removed onChange="didTextChangeInSearchBar" from the <SearchBar> component. Also in the XML, I added searchableText="{title}" to the ListItem within the ListSection to specify the text to be searched. Then, in searchController.js, I added this to the top:
       $.searchList.addEventListener('change', function(e){
       	if($.searchList.value.trim().length >=3 ) {
       		$.listMain.searchText = e.value;
       		Ti.API.info('****** search text = ' + e.value);
       	} else {
       		$.listMain.searchText = '';
       $.searchList.addEventListener('cancel', function(e){
       	$.listMain.searchText = '';
    Using that code, once you've entered three characters into the search box, the list is filtered as expected. If you backspace or tap Cancel, the filter is removed and the entire list contents is removed. You could merge my code here with your didTextChangeInSearchBar() function if you wanted. *Solution 2* Alternatively, you can use the ListView's native filtering function by doing this: Again, start by removing onChange="didTextChangeInSearchBar" from the <SearchBar> component and adding searchableText="{title}" to the ListItem. Then, to searchController.js add this single statement but not the preceding code:
       $.listMain.searchView = $.searchList;
    You can't set this property in the XML (for which I'll file a separate ticket). And it filters automatically on each character you enter (not waiting till you've entered three characters as your use-case specifies). *Environment* * - Ti SDK 3.2.3.GA * - CLI 3.4.0-dev * - Alloy 1.4.0-alpha4 (though there's no reason why my solution above wouldn't also work with 1.3.1) * - Encrypted DB module -- the version that was included with your encDB.zip file * - App version - whatever was in encDB.zip
  2. Tim Poulsen 2014-05-28 Works as expected when using the API techniques as documented and as illustrated in the comments added to the ticket.
  3. Eric Merriman 2018-03-07 Closing as invalid. If this is incorrect, please reopen.

JSON Source