public static IGridColumnOptions <T> Format <T>(this IGridColumnOptions <T> opts, string formatString) { //Contract.Requires( opts != null ); //Contract.Ensures( //Contract.Result<IGridColumnOptions<T>>() != null ); opts.Format = formatString; return(opts); }
public static IGridColumnOptions <T> NotSortable <T>(this IGridColumnOptions <T> opts) { //Contract.Requires( opts != null ); //Contract.Ensures( //Contract.Result<IGridColumnOptions<T>>() != null ); opts.Sortable = false; return(opts); }
public static IGridColumnOptions <T> Title <T>(this IGridColumnOptions <T> opts, string title) { //Contract.Requires( opts != null ); //Contract.Ensures( //Contract.Result<IGridColumnOptions<T>>() != null ); opts.Title = new MvcHtmlString(title); return(opts); }
public static IGridColumnOptions <T> Title <T>(this IGridColumnOptions <T> opts, Func <object, IHtmlString> titleTemplate) { //Contract.Requires( opts != null ); //Contract.Ensures( //Contract.Result<IGridColumnOptions<T>>() != null ); opts.Title = titleTemplate(null); return(opts); }
public static IGridColumnOptions <T> Class <T>(this IGridColumnOptions <T> opts, string className) { //Contract.Requires( opts != null ); //Contract.Ensures( //Contract.Result<IGridColumnOptions<T>>() != null ); var a = new { @class = className }; return(opts.HeaderAttributes(a).CellAttributes(a)); }
public static IGridColumnOptions <T> HeaderAttributes <T>(this IGridColumnOptions <T> opts, object attributes) { //Contract.Requires( opts != null ); //Contract.Requires( attributes != null ); //Contract.Ensures( //Contract.Result<IGridColumnOptions<T>>() != null ); opts.HeaderAttributes = opts.HeaderAttributes.Merge(AttrsFrom(attributes)); return(opts); }
public static IGridColumnOptions <T> Sortable <T>(this IGridColumnOptions <T> opts, string sortProperty) { //Contract.Requires( opts != null ); //Contract.Requires( !String.IsNullOrEmpty( sortProperty ) ); //Contract.Ensures( //Contract.Result<IGridColumnOptions<T>>() != null ); opts.Sortable = true; opts.SortProperty = sortProperty; return(opts); }
public static IGridColumnOptions <T> CellAttributes <T>(this IGridColumnOptions <T> opts, object attributes) { //Contract.Requires( opts != null ); //Contract.Requires( attributes != null ); //Contract.Ensures( //Contract.Result<IGridColumnOptions<T>>() != null ); opts.CellAttributes = opts.CellAttributes.Merge( AttrsFrom(attributes) .ToDictionary(kvp => kvp.Key, kvp => (Func <T, string>)(_ => kvp.Value))); return(opts); }
public static IGridColumnOptions <T> CellAttribute <T>(this IGridColumnOptions <T> opts, string attributeName, Func <T, string> getValue) { //Contract.Requires( opts != null ); //Contract.Requires( !String.IsNullOrEmpty( attributeName ) ); //Contract.Requires( getValue != null ); //Contract.Ensures( //Contract.Result<IGridColumnOptions<T>>() != null ); opts.CellAttributes = opts.CellAttributes.Merge( EnumerableEx.Return(0).ToDictionary(_ => attributeName, _ => getValue)); return(opts); }
/// <summary> /// Modifies a column in such a way that it becomes sortable on the client-side. /// NOTE: if paging is involved, then this sorting will only occur across current page, since other pages do not /// get loaded into the browser at all. /// </summary> /// <param name="col">Column to modify</param> /// <param name="html">HTML helper</param> /// <param name="getJavaScriptSortValue">A function that for each grid row returns a Javascript expression that evaluates to a Javascript value that will be used as the row's value when sorting</param> public static IGridColumnOptions <TRow> ClientSideSort <TRow>(this IGridColumnOptions <TRow> col, HtmlHelper html, Func <TRow, string> getJavaScriptSortValue, bool ascendingByDefault = true) { //Contract.Requires( col != null ); //Contract.Requires( getJavaScriptSortValue != null ); //Contract.Ensures( //Contract.Result<IGridColumnOptions<TRow>>() != null ); var widget = html.Render <IGridClientSortColumn>(); widget.On(col, getJavaScriptSortValue, ascendingByDefault); return(col); }
public void On <TRow>(IGridColumnOptions <TRow> col, Func <TRow, string> getJavaScriptSortValue, bool ascendingByDefault) { col.CellAttributes = col.CellAttributes.Merge( new SortedList <string, Func <TRow, string> > { { "sort-value", getJavaScriptSortValue } }); col.Title(_ => Html.Partial <Views.Grid.GridClientSortColumnTitle>().WithModel(new GridClientSortColumnModel { InnerTitle = col.Title, AscendingByDefault = ascendingByDefault })); }