public BsGridColumn <TRow> Add(string name) { var column = new BsGridColumn <TRow>(name, this.viewContext); this.columns.Add(column); return(column); }
public void Remove <TValue>(Expression <Func <TRow, TValue> > expression) { BsGridColumn <TRow> column = this.GetColumn(expression.GetPropertyInfo <TRow, TValue>()); if (column != null) { this.columns.Remove(column); } }
public BsGridColumn <TRow> Add <TValue>(Expression <Func <TRow, TValue> > expression) { this.Remove(expression); BsGridColumn <TRow> column = new BsGridColumn <TRow>(expression.GetPropertyInfo <TRow, TValue>(), this.viewContext); this.columns.Add(column); return(column); }
internal void SetColumnsFromModel() { this.columns = new List <BsGridColumn <TRow> >(); Type type = typeof(TRow); PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo property in properties) { BsGridColumnAttribute columnAttr = null; if (ReflectionHelpers.TryGetAttribute(property, out columnAttr)) { if (columnAttr.Usage != BsGridColumnUsage.Excel) { var column = new BsGridColumn <TRow>(property, this.viewContext); column.IsSortable = columnAttr.IsSortable; column.SetWidth(columnAttr.Width, columnAttr.MediumWidth, columnAttr.SmallWidth, columnAttr.ExtraSmallWidth); column.SetOrder(columnAttr.Order); System.ComponentModel.DataAnnotations.DisplayAttribute displayAttribute = null; if (ReflectionHelpers.TryGetAttribute(property, out displayAttribute)) { column.DisplayName = displayAttribute.GetName(); } else { column.DisplayName = property.Name; } this.columns.Add(column); } } } }
public BsGridColumn <TRow> For <TValue>(Expression <Func <TRow, TValue> > expression) { BsGridColumn <TRow> column = this.GetColumn(expression.GetPropertyInfo <TRow, TValue>()); return(column); }