/// <summary> /// Initializes a new instance of the <see cref="MonoTouch.SQLite.SQLiteTableViewController`1"/> class. /// </summary> /// <param name='sqlitedb'> /// The SQLite database connection. /// </param> /// <param name='pageSize'> /// The number of items to page-in and page-out as the user scrolls. /// </param> /// <param name='orderBy'> /// The field to sort by and the order in which to display the data or null to display the data in the default order. /// </param> /// <param name='sectionExpression'> /// The sub-expression used to get distinct sections and their titles or null to display the data as a flat list. /// </param> public SQLiteTableViewController(SQLiteConnection sqlitedb, int pageSize, SQLiteOrderBy orderBy, string sectionExpression) : base(UITableViewStyle.Plain, true) { SearchModel = new SQLiteTableModel <T> (sqlitedb, pageSize, orderBy, sectionExpression); Model = new SQLiteTableModel <T> (sqlitedb, pageSize, orderBy, sectionExpression); AutoHideSearch = true; }
public override void ViewDidLoad() { if (Model == null) { Model = CreateModel(false); } if (CanSearch) { if (SearchModel == null) { SearchModel = CreateModel(true); } } base.ViewDidLoad(); if (CanSearch) { SearchDisplayController.SearchResultsTableView.SectionFooterHeight = 0; SearchDisplayController.SearchResultsTableView.AllowsSelection = true; } TableView.SectionFooterHeight = 0; TableView.AllowsSelection = true; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (SearchModel != null) { SearchModel.Dispose(); SearchModel = null; } if (Model != null) { Model.Dispose(); Model = null; } }
/// <summary> /// Gets the path for the given item in the given table view if it is /// currently visible to the user. /// </summary> /// <returns> /// The path for the given item if it is visible, or null if it is not. /// </returns> /// <param name='tableView'> /// The table view that is responsible for displaying the item. /// </param> /// <param name='item'> /// The item to get the path for. /// </param> protected NSIndexPath PathForVisibleItem(UITableView tableView, T item) { SQLiteTableModel <T> model = ModelForTableView(tableView); foreach (var path in tableView.IndexPathsForVisibleRows) { var visibleItem = model.GetItem(path.Section, path.Row); if (visibleItem.Equals(item)) { return(path); } } return(null); }