public GridBoundColumnBuilder <TModel> Bound <TValue>(Expression <Func <TModel, TValue> > expression) { var builder = new GridBoundColumnBuilder <TModel>(_htmlHelper, expression.GetPropertyName(), typeof(TValue)); Columns.Add(builder); return(builder); }
public GridBoundColumnBuilder <TModel> BoundEnum <TValue>(Expression <Func <TModel, TValue?> > expression) where TValue : struct { var builder = new GridBoundColumnBuilder <TModel>(_htmlHelper, expression.GetPropertyName(), typeof(TValue)); var sbTemplate = GetColEnumClientTemplete <TValue>(builder.ColName); builder.ClientTemplate(string.Format("# {0} #", sbTemplate)); Columns.Add(builder); return(builder); }
private GridBoundColumnBuilder <TModel> BoundBool(string colName, string textTrue = "Yes", string textFalse = "No") { var builder = new GridBoundColumnBuilder <TModel>(_htmlHelper, colName); var sb = new StringBuilder(); sb.AppendFormat("if({0}) {{#{1}#}} else {{#{2}#}}", colName, textTrue, textFalse); builder.ClientTemplate(string.Format("# {0} #", sb)); Columns.Add(builder); return(builder); }
private GridBoundColumnBuilder <TModel> BoundBoolImg(string colName, string trueCssClass = "trueImg", string falseCssClass = "falseImg") { var builder = new GridBoundColumnBuilder <TModel>(_htmlHelper, colName); var tb = new TagBuilder("div"); var sb = new StringBuilder(); sb.AppendFormat("if({0}) {{#{1}#}} else {{#{2}#}}", colName, trueCssClass, falseCssClass); tb.Attributes.Add("class", string.Format("# {0} # boundBoolImg", sb)); builder.ClientTemplate(tb.ToString()); Columns.Add(builder); return(builder); }
private string GetRenderJsFuncByClientTemplate(GridBoundColumnBuilder <T> colBuilder) { if (!string.IsNullOrEmpty(colBuilder.ColClientTemplate) && !string.IsNullOrEmpty(colBuilder.ColClientTemplateId)) { throw new Exception(string.Format("Grid column ('{0}') template defenition contains both client tamplate and client tamplate ID. There should be only one defined", colBuilder.ColName)); } if (!string.IsNullOrEmpty(colBuilder.ColClientTemplate)) { return(GetRenderJsFuncByClientTemplate(colBuilder.ColClientTemplate)); } if (!string.IsNullOrEmpty(colBuilder.ColClientTemplateId)) { return(GetRenderJsFuncByClientTemplateId(colBuilder.ColClientTemplateId)); } return(null); }
private GridBoundColumnBuilder <TModel> BoundLink(string colName, string url, string idColName, string colTemplate, object htmlAttributes, string colTitle) { var builder = new GridBoundColumnBuilder <TModel>(_htmlHelper, colName); if (colTitle != null) { builder.ColTitle = colTitle; } int i = url.IndexOf('?'); if (i != -1) { url = url.Insert(i, string.Format("/#={0}#", idColName)); } else { url = url + string.Format("/#={0}#", idColName); } var tb = new TagBuilder("a"); tb.Attributes.Add("id", string.Format("{0}.#={1}#", builder.ColName, idColName)); tb.Attributes.Add("href", url); string innerText = string.IsNullOrEmpty(colTemplate) ? string.Format("#={0}#", builder.ColName) : string.Format("# {0} #", colTemplate); tb.SetInnerText(innerText); if (htmlAttributes != null) { tb.MergeAttributes(HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)); } builder.ClientTemplate(tb.ToString()); Columns.Add(builder); return(builder); }
/* * private string GetColumnTypeName(Type type) * { * return type == typeof (DateTime) ? "date" : null; * } */ private string GetRenderJsFunc(GridBoundColumnBuilder <T> colBuilder) { return((colBuilder.ColType == typeof(DateTime) || colBuilder.ColType == typeof(DateTime?)) ? GetRenderJsFuncDateTimeFormat(colBuilder.ColFormat) : GetRenderJsFuncByClientTemplate(colBuilder)); }