lib/ProMotion/helpers/motion-table/1st/searchable_table.rb in ProMotion-0.1.2 vs lib/ProMotion/helpers/motion-table/1st/searchable_table.rb in ProMotion-0.2.0
- old
+ new
@@ -19,36 +19,40 @@
self.tableView.tableHeaderView = searchBar
end
def searchDisplayController(controller, shouldReloadTableForSearchString:searchString)
- @mt_table_view_groups = []
+ @mt_filtered_data = nil
+ @mt_filtered_data = []
- @original_data.each do |section|
+ @mt_table_view_groups.each do |section|
newSection = {}
newSection[:cells] = []
section[:cells].each do |cell|
if cell[:title].to_s.downcase.strip.include?(searchString.downcase.strip)
newSection[:cells] << cell
end
end
- if newSection.count > 0
+ if newSection[:cells] && newSection[:cells].length > 0
newSection[:title] = section[:title]
- @mt_table_view_groups << newSection
+ @mt_filtered_data << newSection
end
end
-
+
true
end
def searchDisplayControllerWillEndSearch(controller)
- @mt_table_view_groups = @original_data.clone
- @original_data = nil
+ @mt_filtered = false
+ @mt_filtered_data = nil
+ self.tableView.setScrollEnabled true
end
def searchDisplayControllerWillBeginSearch(controller)
- @original_data = @mt_table_view_groups.clone
+ @mt_filtered = true
+ @mt_filtered_data = []
+ self.tableView.setScrollEnabled false
end
end
end
\ No newline at end of file