private static void renderHeader(AwroTagBuilder mainTable, PropertyInfo[] properties) { var tableHead = new AwroTagBuilder("thead"); var headTr = new AwroTagBuilder("tr"); var isCheckedItem = properties.FirstOrDefault(c => c.Name == "IsChecked"); if (isCheckedItem != null) { insertToHeader(headTr, isCheckedItem); } var rownIndexItem = properties.FirstOrDefault(c => c.Name == "RowIndex"); if (rownIndexItem != null) { insertToHeader(headTr, rownIndexItem); } foreach (var item in properties) { if (item.Name != "RowIndex" && item.Name != "IsChecked") { if (item.GetCustomAttribute <DoNotShow>() == null) { insertToHeader(headTr, item); } } } tableHead.InnerHtml += headTr.ToString(); mainTable.InnerHtml += tableHead.ToString(); }
private static void insertToFooter(AwroTagBuilder footerTag, PropertyInfo item) { var td = new AwroTagBuilder("td"); if (item.GetCustomAttribute <AwroGridWidth>() != null) { td.MergeAttribute("style", "width:" + item.GetCustomAttribute <AwroGridWidth>().Value); } //td.InnerHtml += item.GetCustomAttribute<DisplayAttribute>() != null ? item.GetCustomAttribute<DisplayAttribute>().GetName() : item.Name; footerTag.InnerHtml += td.ToString(); }
private static void insertToHeader(AwroTagBuilder headTr, PropertyInfo item) { var th = new AwroTagBuilder("th"); th.MergeAttribute("scope", "col"); if (item.GetCustomAttribute <AwroGridWidth>() != null) { th.MergeAttribute("style", "width:" + item.GetCustomAttribute <AwroGridWidth>().Value); } th.InnerHtml += item.GetCustomAttribute <DisplayAttribute>() != null?item.GetCustomAttribute <DisplayAttribute>().GetName() : item.Name; headTr.InnerHtml += th.ToString(); }
private static void renderFooter(AwroTagBuilder mainTable, PropertyInfo[] properties) { var footer = new AwroTagBuilder("tfoot"); var footerTr = new AwroTagBuilder("tr"); foreach (var item in properties) { if (item.GetCustomAttribute <DoNotShow>() == null) { insertToFooter(footerTr, item); } } footer.InnerHtml += footerTr.ToString(); mainTable.InnerHtml += footer.ToString(); }
private static void renderBody(AwroTagBuilder mainTable) { var tbody = new AwroTagBuilder("tbody"); mainTable.InnerHtml += tbody.ToString(); }
public static HtmlString JGrid2 <TModel, TValue>(this IHtmlHelper <TModel> html, string gridName, string objectName, bool showPaging, bool showFooter, bool isReadOnlyGrid, Dictionary <string, bool> showIfParameters) { showPaging = false; var mainDiv = new AwroTagBuilder("div"); mainDiv.MergeAttribute("class", "row fourth six"); mainDiv.MergeAttribute("id", gridName); var properties = typeof(TValue).GetProperties(); properties = setOrders(properties); if (showIfParameters != null) { var doNotShowList = showIfParameters.Where(c => !c.Value); if (doNotShowList != null && showIfParameters.Count() > 0) { var shareList = properties.Join(doNotShowList, c => c.Name, c => c.Key, (first, second) => first); properties = properties.Except(shareList).ToArray(); } } mainDiv.InnerHtml += createHeaderColumnsList(properties, gridName, objectName, isReadOnlyGrid); mainDiv.InnerHtml += createNewRow(properties, gridName); var secondDiv = new AwroTagBuilder("div"); secondDiv.MergeAttribute("class", "col-sm-12"); var holderDive = new AwroTagBuilder("div"); holderDive.MergeAttribute("class", "col-sm-12"); holderDive.MergeAttribute("style", "padding:0;"); var hasWaitingDiv = new AwroTagBuilder("div"); hasWaitingDiv.MergeAttribute("class", "has-waiting table-responsive"); var mainTable = new AwroTagBuilder("table"); mainTable.MergeAttribute("class", "table table-bordered table-hover inline-edit"); renderTable(mainTable, properties, showFooter); hasWaitingDiv.InnerHtml += mainTable.ToString(); var waitingDiv = new AwroTagBuilder("div"); waitingDiv.MergeAttribute("class", "waiting"); waitingDiv.MergeAttribute("style", "display:none"); var spanWaiting = new AwroTagBuilder("span"); waitingDiv.InnerHtml += spanWaiting; hasWaitingDiv.InnerHtml += waitingDiv; holderDive.InnerHtml += hasWaitingDiv; secondDiv.InnerHtml += holderDive; if (showPaging) { var nav = createNavigation(); secondDiv.InnerHtml += nav.ToString(); } mainDiv.InnerHtml += secondDiv.ToString(); // initiateGrid(gridName, mainDiv); return(new HtmlString(mainDiv.ToString())); }