protected override bool PopulateCell(SDataGridDataSourceHelper helper, SDataGridCell cell, NSObject value, string propertyKey, NSObject source) { // the table has a custom cell, AvatarCell. This method override is used // to populate this custom cell type. if (propertyKey == "reported") { AvatarCell avatarCell = (AvatarCell)cell; avatarCell.AvatarUrl = (NSString)value; return(true); } return(false); }
protected override NSObject DisplayValueForProperty(SDataGridDataSourceHelper helper, string propertyKey, NSObject source) { IssueDataItem issue = (IssueDataItem)source; NSObject value = GetProperty(issue, propertyKey); // for the date column, we specialise the formatting if (propertyKey == "created_at") { DateTime created = issue.created_at; value = (NSString)created.ToString("dd-MM-yyyy"); } return(value); }
void CreateDataGrid() { // create a datagrid _dataGrid = new ShinobiDataGrid(this.Bounds); _dataGrid.LicenseKey = ShinobiLicenseKeyProviderJson.Instance.GridsLicenseKey; _dataGrid.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; // styling _dataGrid.DefaultCellStyleForAlternateRows = new SDataGridCellStyle(new UIColor(0.9f, 0.9f, 0.9f, 1.0f), null, null); _dataGrid.DefaultGridLineStyle = new SDataGridLineStyle(0.0f, UIColor.Clear); // add the columns SDataGridColumn createdDateColumn = new SDataGridColumn("created", "created_at"); createdDateColumn.SortMode = SDataGridColumnSortMode.TriState; createdDateColumn.Width = new NSNumber(150); _dataGrid.AddColumn(createdDateColumn); SDataGridColumn titleColumn = new SDataGridColumn("title", "title"); titleColumn.SortMode = SDataGridColumnSortMode.TriState; titleColumn.Width = new NSNumber(795); _dataGrid.AddColumn(titleColumn); // reported column, using a custom cell type SDataGridColumn reportedColumn = new SDataGridColumn(" ", "reported", new Class("AvatarCell"), new Class("SDataGridHeaderCell")); reportedColumn.Width = new NSNumber(50); _dataGrid.AddColumn(reportedColumn); // provide a datasource helper. This acts as both the datasource and the delegate _dataSourceHelper = new SDataGridDataSourceHelper(_dataGrid); _dataSourceHelper.GroupedPropertyKey = "created_at"; _dataSourceHelper.GroupedPropertySortOrder = SDataGridColumnSortOrder.Descending; _dataSourceHelper.Delegate = new IssuesDataGridHelperDelegate(); this.Add(_dataGrid); }
protected override NSObject SortValueForProperty(SDataGridDataSourceHelper helper, string propertyKey, NSObject source) { return(GetProperty((IssueDataItem)source, propertyKey)); }