/// <summary> /// Reloads the data. /// </summary> public void ReloadData() { if (CanSearch) { SearchModel.ReloadData(); } Model.ReloadData(); if (SearchDisplayController != null) { SearchDisplayController.SearchResultsTableView.ReloadData(); } TableView.ReloadData(); }
void OnAircraftDeleted(UITableView tableView, NSIndexPath indexPath) { // Reset the models... SearchModel.ReloadData(); Model.ReloadData(); tableView.DeleteRows(new [] { indexPath }, UITableViewRowAnimation.Automatic); if (tableView != TableView) { // We've already deleted the item from the search model, but we // have no way of knowing its section/row in the normal model. TableView.ReloadData(); } else if (Model.SectionCount == 0) { OnAddClicked(null, null); return; } // Update the selection... var model = ModelForTableView(tableView); int count = model.GetRowCount(indexPath.Section); NSIndexPath path; if (indexPath.Row >= count) { path = NSIndexPath.FromRowSection(count - 1, indexPath.Section); } else { path = indexPath; } tableView.SelectRow(path, true, UITableViewScrollPosition.None); RowSelected(tableView, path); }
void OnFlightDeleted(UITableView tableView, NSIndexPath indexPath) { var model = ModelForTableView(tableView); if (model.GetRowCount(indexPath.Section) > 1) { // The section contains more than just this row, so delete only the row. var rows = new NSIndexPath[1]; rows[0] = indexPath; // Reset the models... SearchModel.ReloadData(); Model.ReloadData(); tableView.DeleteRows(rows, UITableViewRowAnimation.Automatic); } else { // This section only has the row the user is deleting, so remove the entire section. using (var sections = NSIndexSet.FromIndex(indexPath.Section)) { // Reset the models... SearchModel.ReloadData(); Model.ReloadData(); tableView.DeleteSections(sections, UITableViewRowAnimation.Automatic); } } if (tableView != TableView) { // We've already deleted the item from the search model, but we // have no way of knowing its section/row in the normal model. TableView.ReloadData(); } else if (Model.SectionCount == 0) { OnAddClicked(null, null); return; } // Update the selection... int section, row; int count; if (indexPath.Section >= model.SectionCount) { // Select the last row of the last section section = model.SectionCount - 1; row = model.GetRowCount(section) - 1; } else { section = indexPath.Section; count = model.GetRowCount(section); if (indexPath.Row < count) { row = indexPath.Row; } else { row = count - 1; } } NSIndexPath path = NSIndexPath.FromRowSection(row, section); tableView.SelectRow(path, true, UITableViewScrollPosition.None); RowSelected(tableView, path); }