コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }