public static ITree <TNode> NodeAttributes <TNode>(this ITree <TNode> tree, Func <TNode, object> attrs) { //Contract.Requires( tree != null ); return(tree.With(o => o.NodeAttributes = n => { var aa = attrs(n); return aa == null ? null : ObjectDictionary.From(aa).ToDictionary(k => k.Key, k => Convert.ToString(k.Value)); })); }
public AjaxJsonResponseResult(object json) { _json = ObjectDictionary.From(json ?? new object()); }
public static ITree <TNode> TreeAttributes <TNode>(this ITree <TNode> tree, object attrs) { //Contract.Requires( tree != null ); return(tree.With(o => o.TreeAttributes = attrs == null ? null : ObjectDictionary.From(attrs).ToDictionary(k => k.Key, k => Convert.ToString(k.Value)))); }
public override void Execute() { #line 3 "..\..\Views\Grid\Grid.cshtml" Layout = null; var attributes = ObjectDictionary.From(new { id = "Grid_" + Guid.NewGuid().ToString().Substring(0, 6).Replace("-", ""), @class = "Grid", cellspacing = "0", cellpadding = "0" }) .ToDictionary(k => k.Key, k => Convert.ToString(k.Value)) .Merge(Model.Options.Attributes); var id = attributes["id"]; this.Stylesheet("grid.css"); #line default #line hidden WriteLiteral("\r\n\r\n<table "); #line 19 "..\..\Views\Grid\Grid.cshtml" Write(Attributes(attributes)); #line default #line hidden WriteLiteral(">\r\n <thead>\r\n <tr>\r\n"); #line 22 "..\..\Views\Grid\Grid.cshtml" #line default #line hidden #line 22 "..\..\Views\Grid\Grid.cshtml" foreach (var c in Model.Columns) { var headerClass = c.HeaderAttributes == null ? null : c.HeaderAttributes.ValueOrDefault("class"); if (!string.IsNullOrEmpty(headerClass)) { headerClass += " "; } if (c.Sortable) { headerClass += "Sortable"; if (c.SortProperty == Model.Options.CurrentSort) { headerClass += Model.Options.CurrentSortIsAscending ? " SortedAsc" : " SortedDesc"; } } #line default #line hidden WriteLiteral(" <th "); #line 35 "..\..\Views\Grid\Grid.cshtml" Write(Attribute("class", headerClass)); #line default #line hidden #line 35 "..\..\Views\Grid\Grid.cshtml" Write(Attribute("sortby", c.Sortable ? c.SortProperty : null)); #line default #line hidden WriteLiteral("\r\n"); WriteLiteral(" "); #line 36 "..\..\Views\Grid\Grid.cshtml" Write(Attributes(c.HeaderAttributes, "class")); #line default #line hidden WriteLiteral(">\r\n"); #line 37 "..\..\Views\Grid\Grid.cshtml" #line default #line hidden #line 37 "..\..\Views\Grid\Grid.cshtml" if (c.Sortable && c.SortProperty == Model.Options.CurrentSort) { #line default #line hidden WriteLiteral(" <div"); WriteLiteral(" class=\"SortIcon\""); WriteLiteral("> </div> "); #line 37 "..\..\Views\Grid\Grid.cshtml" } #line default #line hidden WriteLiteral(" "); #line 38 "..\..\Views\Grid\Grid.cshtml" Write(c.Title); #line default #line hidden WriteLiteral("\r\n </th>\r\n"); #line 40 "..\..\Views\Grid\Grid.cshtml" } #line default #line hidden WriteLiteral(" </tr>\r\n </thead>\r\n <tbody>\r\n"); #line 44 "..\..\Views\Grid\Grid.cshtml" #line default #line hidden #line 44 "..\..\Views\Grid\Grid.cshtml" var altClasses = Model.Options.AlternatingRowCssClasses.EmptyIfNull().DefaultIfEmpty(); var pageFilled = Model.Options.PageSize; var totalColumns = Model.Columns.Count(); #line default #line hidden WriteLiteral("\r\n"); #line 49 "..\..\Views\Grid\Grid.cshtml" #line default #line hidden #line 49 "..\..\Views\Grid\Grid.cshtml" foreach (var r in Model.Rows.Zip(altClasses.Repeat(), (row, cls) => new { row, cls })) { pageFilled--; #line default #line hidden WriteLiteral(" <tr "); #line 52 "..\..\Views\Grid\Grid.cshtml" Write(Attribute("class", r.cls)); #line default #line hidden #line 52 "..\..\Views\Grid\Grid.cshtml" Write(Attribute("id", r.row.Id)); #line default #line hidden WriteLiteral(">\r\n"); #line 53 "..\..\Views\Grid\Grid.cshtml" #line default #line hidden #line 53 "..\..\Views\Grid\Grid.cshtml" foreach (var c in r.row.Cells) { #line default #line hidden WriteLiteral(" <td "); #line 55 "..\..\Views\Grid\Grid.cshtml" Write(Attributes(c.Attributes)); #line default #line hidden WriteLiteral(">"); #line 55 "..\..\Views\Grid\Grid.cshtml" Write(c.Content); #line default #line hidden WriteLiteral("</td>\r\n"); #line 56 "..\..\Views\Grid\Grid.cshtml" } #line default #line hidden WriteLiteral(" </tr>\r\n"); #line 58 "..\..\Views\Grid\Grid.cshtml" } #line default #line hidden WriteLiteral(" "); #line 59 "..\..\Views\Grid\Grid.cshtml" while (Model.Options.TotalPages > 1 && pageFilled-- > 0) { #line default #line hidden WriteLiteral(" <tr><td"); WriteAttribute("colspan", Tuple.Create(" colspan=\"", 2339), Tuple.Create("\"", 2362) #line 61 "..\..\Views\Grid\Grid.cshtml" , Tuple.Create(Tuple.Create("", 2349), Tuple.Create <System.Object, System.Int32>(totalColumns #line default #line hidden , 2349), false) ); WriteLiteral("> </td></tr>\r\n"); #line 62 "..\..\Views\Grid\Grid.cshtml" } #line default #line hidden WriteLiteral(" "); #line 63 "..\..\Views\Grid\Grid.cshtml" if (!Model.Rows.Any()) { #line default #line hidden WriteLiteral(" <tr><td"); WriteAttribute("colspan", Tuple.Create(" colspan=\"", 2459), Tuple.Create("\"", 2482) #line 65 "..\..\Views\Grid\Grid.cshtml" , Tuple.Create(Tuple.Create("", 2469), Tuple.Create <System.Object, System.Int32>(totalColumns #line default #line hidden , 2469), false) ); WriteLiteral(" class=\"NoData\""); WriteLiteral(">"); #line 65 "..\..\Views\Grid\Grid.cshtml" Write(Model.Options.NoDataMessage(null)); #line default #line hidden WriteLiteral("</td></tr>\r\n"); #line 66 "..\..\Views\Grid\Grid.cshtml" } #line default #line hidden WriteLiteral(" </tbody>\r\n"); #line 68 "..\..\Views\Grid\Grid.cshtml" #line default #line hidden #line 68 "..\..\Views\Grid\Grid.cshtml" if ((Model.Options.IsPaged && Model.Options.TotalPages > 1) || Model.Options.FooterPrefix != null || Model.Options.FooterSuffix != null) { #line default #line hidden WriteLiteral(" <tfoot>\r\n <tr><td"); WriteAttribute("colspan", Tuple.Create(" colspan=\"", 2760), Tuple.Create("\"", 2783) #line 71 "..\..\Views\Grid\Grid.cshtml" , Tuple.Create(Tuple.Create("", 2770), Tuple.Create <System.Object, System.Int32>(totalColumns #line default #line hidden , 2770), false) ); WriteLiteral(">\r\n"); WriteLiteral(" "); #line 72 "..\..\Views\Grid\Grid.cshtml" Write(Model.Options.FooterPrefix); #line default #line hidden WriteLiteral("\r\n"); #line 73 "..\..\Views\Grid\Grid.cshtml" #line default #line hidden #line 73 "..\..\Views\Grid\Grid.cshtml" if (Model.Options.IsPaged && Model.Options.TotalPages > 1) { #line default #line hidden WriteLiteral(" <div"); WriteLiteral(" class=\"Pager\""); WriteLiteral(">\r\n"); #line 76 "..\..\Views\Grid\Grid.cshtml" #line default #line hidden #line 76 "..\..\Views\Grid\Grid.cshtml" var abbreviate = Model.Options.TotalPages > Model.Options.MaxPageButtonsBeforeAbbreviating; var minPage = abbreviate ? Math.Max(0, Model.Options.CurrentPage - Model.Options.PageButtonsWhenAbbreviated / 2) : 0; var maxPage = abbreviate ? Math.Min(Model.Options.TotalPages - 1, minPage + Model.Options.PageButtonsWhenAbbreviated - 1) : Model.Options.TotalPages - 1; if (abbreviate) { #line default #line hidden #line 83 "..\..\Views\Grid\Grid.cshtml" Write(PageArrow("<<", 0)); #line default #line hidden #line 83 "..\..\Views\Grid\Grid.cshtml" #line default #line hidden #line 84 "..\..\Views\Grid\Grid.cshtml" Write(PageArrow("<", Model.Options.CurrentPage - 1)); #line default #line hidden #line 84 "..\..\Views\Grid\Grid.cshtml" if (minPage > 0) { #line default #line hidden WriteLiteral(" <div"); WriteLiteral(" class=\"AbbreviationEllipsis\""); WriteLiteral(">...</div> "); #line 86 "..\..\Views\Grid\Grid.cshtml" } } else { #line default #line hidden WriteLiteral(" "); WriteLiteral("Page:"); WriteLiteral(" "); #line 89 "..\..\Views\Grid\Grid.cshtml" } for (int page = minPage; page <= maxPage; page++) { #line default #line hidden WriteLiteral(" <a"); WriteLiteral(" href=\"#\""); WriteAttribute("page", Tuple.Create(" page=\"", 3951), Tuple.Create("\"", 3963) #line 93 "..\..\Views\Grid\Grid.cshtml" , Tuple.Create(Tuple.Create("", 3958), Tuple.Create <System.Object, System.Int32>(page #line default #line hidden , 3958), false) ); WriteAttribute("class", Tuple.Create(" class=\"", 3964), Tuple.Create("\"", 4032) , Tuple.Create(Tuple.Create("", 3972), Tuple.Create("Page", 3972), true) #line 93 "..\..\Views\Grid\Grid.cshtml" , Tuple.Create(Tuple.Create("", 3976), Tuple.Create <System.Object, System.Int32>(page == Model.Options.CurrentPage ? " Selected" : "" #line default #line hidden , 3976), false) ); WriteLiteral(">"); #line 93 "..\..\Views\Grid\Grid.cshtml" Write(page + 1); #line default #line hidden WriteLiteral("</a>\r\n"); #line 94 "..\..\Views\Grid\Grid.cshtml" } if (abbreviate) { if (maxPage < Model.Options.TotalPages - 1) { #line default #line hidden WriteLiteral(" <div"); WriteLiteral(" class=\"AbbreviationEllipsis\""); WriteLiteral(">...</div> "); #line 99 "..\..\Views\Grid\Grid.cshtml" } #line default #line hidden #line 100 "..\..\Views\Grid\Grid.cshtml" Write(PageArrow(">", Model.Options.CurrentPage + 1)); #line default #line hidden #line 100 "..\..\Views\Grid\Grid.cshtml" #line default #line hidden #line 101 "..\..\Views\Grid\Grid.cshtml" Write(PageArrow(">>", Model.Options.TotalPages - 1)); #line default #line hidden #line 101 "..\..\Views\Grid\Grid.cshtml" } #line default #line hidden WriteLiteral("\r\n </div>\r\n"); #line 105 "..\..\Views\Grid\Grid.cshtml" } #line default #line hidden WriteLiteral(" "); #line 106 "..\..\Views\Grid\Grid.cshtml" Write(Model.Options.FooterSuffix); #line default #line hidden WriteLiteral("\r\n </td></tr>\r\n </tfoot>\r\n"); #line 109 "..\..\Views\Grid\Grid.cshtml" } #line default #line hidden WriteLiteral(" <script>\r\n //"); WriteLiteral("@ sourceURL=http://lpp/Grid.cshtml\r\n $(function () {\r\n $(\"#"); #line 113 "..\..\Views\Grid\Grid.cshtml" Write(id); #line default #line hidden WriteLiteral("\").grid(\""); #line 113 "..\..\Views\Grid\Grid.cshtml" Write(Html.Raw(Model.Options.ReloadUrl)); #line default #line hidden WriteLiteral("\");\r\n });\r\n </script>\r\n"); WriteLiteral(" "); #line 116 "..\..\Views\Grid\Grid.cshtml" Write(Model.Options.Appendix); #line default #line hidden WriteLiteral("\r\n</table>\r\n\r\n"); }
static IDictionary <string, string> AttrsFrom(object attributes) { return(ObjectDictionary.From(attributes).ToDictionary(k => k.Key, k => Convert.ToString(k.Value))); }