Exemplo n.º 1
0
        public ColumnViewModel <T> AddCustomColumn(string name)
        {
            var newColumn = new ColumnViewModel <T>(name);

            Columns.Add(newColumn);
            return(newColumn);
        }
Exemplo n.º 2
0
        public static ColumnViewModel <T> WithLink <T>(this ColumnViewModel <T> col, Func <T, string> link)
        {
            col.HtmlDisplayValue = (vc, html, x) => new HtmlString(
                string.IsNullOrWhiteSpace(link(x)) ? HttpUtility.HtmlEncode(col.GetValue(x)) :
                string.Format("<a href=\"{0}\">{1}</a>", link(x), HttpUtility.HtmlEncode(col.GetValue(x))));

            return(col);
        }
Exemplo n.º 3
0
        public static ColumnViewModel <T> WithLinkInNewWindow <T>(this ColumnViewModel <T> col, Func <T, string> link, string cssclasses, Func <T, string> refFunc)
        {
            col.HtmlDisplayValue = (vc, html, x) => new HtmlString(
                string.Format("<a href=\"{0}\" class=\"{2}\" ref=\"{3}\" target=\"_blank\">{1}</a>",
                              link(x), HttpUtility.HtmlEncode(col.GetValue(x)), cssclasses, refFunc(x)));

            return(col);
        }
Exemplo n.º 4
0
        public static ColumnViewModel <T> AsLink <T>(this ColumnViewModel <T> col)
        {
            col.HtmlDisplayValue = (vc, html, x) => new HtmlString(
                string.Format("<a href=\"{0}\">{0}</a>",
                              col.GetValue(x)));

            return(col);
        }
Exemplo n.º 5
0
        public static ColumnViewModel <T> AsLink <T>(this ColumnViewModel <T> col, string linkText)
        {
            col.HtmlDisplayValue = (vc, html, x) => new HtmlString(
                string.Format("<a href=\"{0}\">{1}</a>",
                              col.GetValue(x), HttpUtility.HtmlEncode(linkText)));

            return(col);
        }
Exemplo n.º 6
0
        public ColumnViewModel <T> AddColumn(Expression <Func <T, object> > action)
        {
            MemberExpression body = null;

            if (action.Body is MemberExpression)
            {
                body = ((MemberExpression)(action.Body));
            }
            if (action.Body is UnaryExpression)
            {
                body = ((MemberExpression)((UnaryExpression)(action.Body)).Operand);
            }

            var propType = typeof(T).GetProperty(body.Member.Name);

            var col = new ColumnViewModel <T>(propType);

            Columns.Add(col);
            return(col);
        }
Exemplo n.º 7
0
 public static ColumnViewModel <T> Shorten <T>(this ColumnViewModel <T> col, int max)
 {
     col.Shorten(max, "...");
     return(col);
 }
 public static ColumnViewModel <T> DisplayName <T>(this ColumnViewModel <T> col, string displayName)
 {
     col.DisplayName = displayName;
     return(col);
 }
 public static ColumnViewModel <T> WithHeaderName <T>(this ColumnViewModel <T> col, string name)
 {
     col.DisplayName = name;
     return(col);
 }
 public static ColumnViewModel <T> Searchable <T>(this ColumnViewModel <T> col)
 {
     col.Searchable = true;
     return(col);
 }
 public static ColumnViewModel <T> CellClasses <T>(this ColumnViewModel <T> col, string cellClasses)
 {
     col.CellClasses = cellClasses;
     return(col);
 }
Exemplo n.º 12
0
 public static ColumnViewModel <T> WithLinkInNewWindow <T>(this ColumnViewModel <T> col, Func <T, string> link, string cssclasses)
 {
     return(WithLinkInNewWindow(col, link, string.Empty, (x) => string.Empty));
 }
 public static ColumnViewModel <T> NotSortable <T>(this ColumnViewModel <T> col)
 {
     col.Sortable = false;
     return(col);
 }
Exemplo n.º 14
0
 public static ColumnViewModel <T> Shorten <T>(this ColumnViewModel <T> col, int max, string maxString)
 {
     col.WithDisplayValue(x => col.GetValue(x.Data).Length > max ? col.GetValue(x.Data).Substring(0, max) + maxString : col.GetValue(x.Data));
     return(col);
 }
 public static ColumnViewModel <T> DisplayValueFormatter <T>(this ColumnViewModel <T> col, string displayValueFormatter)
 {
     col.DisplayValueFormatter = displayValueFormatter;
     return(col);
 }
Exemplo n.º 16
0
 public static ColumnViewModel <T> AsReversedYesNo <T>(this ColumnViewModel <T> col)
 {
     col.WithDisplayValue(x => (col.GetValue(x.Data) ?? string.Empty)
                          .Equals(false.ToString(), StringComparison.InvariantCultureIgnoreCase) ? "Yes" : "No");
     return(col);
 }
 public static ColumnViewModel <T> WithHtmlDisplayValue <T>(this ColumnViewModel <T> col, Func <ColumnViewData <T>, IHtmlString> htmlDisplayValue)
 {
     col.HtmlDisplayValue = (vc, html, o) => htmlDisplayValue(new ColumnViewData <T>(vc, html, o));
     return(col);
 }
 public static ColumnViewModel <T> WithTooltip <T>(this ColumnViewModel <T> col, Func <T, string> tooltip)
 {
     col.Tooltip = tooltip;
     return(col);
 }
 public static ColumnViewModel <T> Hide <T>(this ColumnViewModel <T> col)
 {
     col.Visible = false;
     return(col);
 }
Exemplo n.º 20
0
 public static ColumnViewModel <T> AsDate <T>(this ColumnViewModel <T> col)
 {
     col.WithDisplayValueFormat("{0:dd.MM.yy}");
     return(col);
 }
 public static ColumnViewModel <T> WithDisplayValueFormat <T>(this ColumnViewModel <T> col, string format)
 {
     col.DisplayValueFormatter = format;
     return(col);
 }
Exemplo n.º 22
0
 public static ColumnViewModel <T> ShortenWithFullTooltip <T>(this ColumnViewModel <T> col, int max)
 {
     col.Shorten(max, "...");
     col.WithTooltip((o) => col.GetValue(o));
     return(col);
 }
 public static ColumnViewModel <T> NullValue <T>(this ColumnViewModel <T> col, string nullValue)
 {
     col.NullValue = nullValue;
     return(col);
 }