private HtmlComposite BuildTableBody <T>(ClassSelectResult <T> result) { ClassSchema <T> aspect = ClassSchema <T> .Instance; HtmlComposite tbody = new HtmlComposite("tbody"); AspectMember[] onclickMembers = OnClickColumns != null && OnClickColumns.Length > 0 ? new AspectMember[OnClickColumns.Length] : null; if (onclickMembers != null) { for (int i = 0; i < onclickMembers.Length; i++) { onclickMembers[i] = aspect[OnClickColumns[i]]; } } object[] onclickValues = OnClickColumns != null && OnClickColumns.Length > 0 ? new object[OnClickColumns.Length] : null; AspectMember[] members = new AspectMember[columns.Count]; for (int i = 0; i < members.Length; i++) { members[i] = aspect[columns[i].Name]; } foreach (T child in result) { HtmlComposite tr = tbody.AppendComposite("tr"); if (!string.IsNullOrEmpty(this.OnClickFormatString)) { if (onclickValues != null) { for (int i = 0; i < onclickValues.Length; i++) { onclickValues[i] = onclickMembers[i].GetValue(child); } tr .AppendAttribute("style", "cursor:pointer") .AppendAttribute("onclick", string.Format(this.OnClickFormatString, onclickValues)); } else { tr .AppendAttribute("style", "cursor:pointer") .AppendAttribute("onclick", this.OnClickFormatString); } } for (int i = 0; i < members.Length; i++) { BootstrapQueryHelperColumn col = columns[i]; HtmlComposite td = tr.AppendComposite("td"); if (!string.IsNullOrEmpty(col.CssStyle)) { td.AppendAttribute("style", col.CssStyle); } if (!string.IsNullOrEmpty(col.CssClass)) { td.AppendAttribute("class", col.CssClass); } object value = members[i].GetValue(child); string content = col.Formatter.Format(value, CultureInfo.CurrentUICulture); if (col.IsHtmlRaw) { td.Children.AddLast(new HtmlRaw(content)); } else { td.AppendText(content); } } } return(tbody); }
private HtmlComposite BuildTableHeader <T>() { HtmlComposite thead = new HtmlComposite("thead"); HtmlComposite thead_tr = thead.AppendComposite("tr"); foreach (BootstrapQueryHelperColumn col in this.columns) { HtmlComposite th = thead_tr.AppendComposite("th"); HtmlComposite tha = th.AppendComposite("a"); tha.AppendText(col.Caption + " "); tha.AppendAttribute("href", "javascript:void(0)"); if (col.Name.Equals(this.OrderBy, StringComparison.OrdinalIgnoreCase)) { if (this.OrderByDirection == EixoX.Data.SortDirection.Ascending) { tha.AppendSimple( "span", "", new HtmlAttribute("class", "fa fa-sort-asc")); tha.AppendAttribute("onclick", string.Concat("EixoX.sortGrid(this,'", col.Name, "','", EixoX.Data.SortDirection.Descending, "')")); } else { tha.AppendSimple( "span", "", new HtmlAttribute("class", "fa fa-sort-desc")); tha.AppendAttribute("onclick", string.Concat("EixoX.sortGrid(this,'", col.Name, "','", EixoX.Data.SortDirection.Ascending, "')")); } } else { tha.AppendSimple( "span", "", new HtmlAttribute("class", "fa fa-sort")); tha.AppendAttribute("onclick", string.Concat("EixoX.sortGrid(this,'", col.Name, "','", EixoX.Data.SortDirection.Ascending, "')")); } } HtmlComposite tr2 = thead.AppendComposite("tr"); foreach (BootstrapQueryHelperColumn col in this.columns) { HtmlComposite th2 = tr2.AppendComposite( "td", new HtmlAttribute("style", "padding:0px") ); th2.AppendStandalone( "input", new HtmlAttribute("type", "text"), new HtmlAttribute("placeholder", "filtrar"), new HtmlAttribute("name", col.Name), new HtmlAttribute("value", col.Filter), new HtmlAttribute("style", "margin:0px; border-radius:0px; display:block; width:94%; border:none;")); } return(thead); }