Exemple #1
0
        public virtual void RenderTableHeader()
        {
            Writer.Write("<thead>");
            Writer.Write("<tr>");
            var nextSortOrder = GridModel.Multisort ? (OrderedVisibleColumns.Any(x => x.Value.SortOrder.HasValue)
                                           ? (OrderedVisibleColumns.Where(x => x.Value.SortOrder.HasValue).Max(x => x.Value.SortOrder) + 1) : 0)
                                           : 0;

            if (IsGroupGrid || GridModel.HierarchyUrl != null)
            {
                Writer.Write("<th class=\"hierarchy-cell\"></th>");
            }

            foreach (var column in OrderedVisibleColumns)
            {
                RenderColumnHeader(column.Value, column.Key, nextSortOrder.GetValueOrDefault(0), false);
            }

            if (IsGroupGrid || GridModel.HierarchyUrl != null)
            {
                Writer.Write("<th class=\"hierarchy-cell-right\"></th>");
            }

            Writer.Write("</tr>");
            Writer.Write("</thead>");
        }
        public override void RenderGroupTable(TModel[] items, IGridGroupOptions groupOptions, IPagedList paginationViewModel)
        {
            var isHierarchy = GridModel.HierarchyUrl != null;

            Writer.Write("<div class=\"grid-group-wrap\">");
            Writer.Write("<table class=\"grid-group-table\"><thead>");
            var nextSortOrder = GridModel.Multisort ? (OrderedVisibleColumns.Any(x => x.Value.SortOrder.HasValue)
                                           ? (OrderedVisibleColumns.Where(x => x.Value.SortOrder.HasValue).Max(x => x.Value.SortOrder) + 1) : 0)
                                           : 0;

            if (isHierarchy)
            {
                Writer.Write("<th class=\"hierarchy-cell\"></th>");
            }

            foreach (var column in OrderedVisibleColumns)
            {
                RenderColumnHeader(column.Value, column.Key, nextSortOrder.GetValueOrDefault(0), true);
            }

            if (isHierarchy)
            {
                Writer.Write("<th class=\"hierarchy-cell-right\"></th>");
            }

            Writer.Write("</thead>");
            Writer.Write("<tbody>");
            var alternate = false;

            for (var i = 0; i < items.Length; i++)
            {
                RenderTableRow(items[i], OrderedVisibleColumns, alternate);
                alternate = !alternate;
            }

            if (GridModel.ShowEmptyRowsInGroup)
            {
                for (var i = items.Length; i < GridModel.PageSizeInGroup; i++)
                {
                    RenderTableRow(null, OrderedVisibleColumns, alternate, empty: true);
                    alternate = !alternate;
                }
            }

            if (items.Length == 0)
            {
                Writer.Write("<tr>");
                Writer.Write("<td class=\"empty-grid-row\" colspan=\"{1}\">{0}</td>", GridRenderOptions.EmptyText,
                             OrderedVisibleColumns.Count() + 2);
                Writer.Write("</tr>");
            }
            else
            {
                RenderSummaryRow(items, OrderedVisibleColumns.ToArray());
            }

            Writer.Write("</tbody>");
            Writer.Write("</table>");

            RenderGroupGridState(groupOptions);

            RenderPager(paginationViewModel, GridGroupPageLinkClass, true);

            Writer.Write("</div>");
        }