diff --git a/src/DotVVM.Framework/Controls/GridView.cs b/src/DotVVM.Framework/Controls/GridView.cs index 6676b6650d..7836759f88 100644 --- a/src/DotVVM.Framework/Controls/GridView.cs +++ b/src/DotVVM.Framework/Controls/GridView.cs @@ -153,7 +153,7 @@ protected internal override void OnPreRender(Hosting.IDotvvmRequestContext conte DataBind(context); // TODO: support for observable collection base.OnPreRender(context); } - + private void DataBind(IDotvvmRequestContext context) { Children.Clear(); @@ -176,7 +176,8 @@ dataSource is ISortableGridViewDataSet sortableSet && sortableSet.SortingOptions sortOptions.SortDescending = false; } (sortableSet as IPageableGridViewDataSet)?.GoToFirstPage(); - } : + } + : SortChanged; // WORKAROUND: DataSource is null => don't throw exception @@ -187,7 +188,8 @@ dataSource is ISortableGridViewDataSet sortableSet && sortableSet.SortingOptions }; } - CreateHeaderRow(context, sortCommand); + var header = CreateHeaderRow(context, sortCommand); + Children.Add(header); var index = 0; if (dataSource != null) { @@ -223,10 +225,9 @@ dataSource is ISortableGridViewDataSet sortableSet && sortableSet.SortingOptions } } - private void CreateHeaderRow(IDotvvmRequestContext context, Action sortCommand) + protected virtual HtmlGenericControl CreateHeaderRow(IDotvvmRequestContext context, Action sortCommand) { head = new HtmlGenericControl("thead"); - Children.Add(head); var gridViewDataSet = DataSource as IGridViewDataSet; @@ -257,6 +258,8 @@ private void CreateHeaderRow(IDotvvmRequestContext context, Action sortC column.CreateFilterControls(context, this, cell, gridViewDataSet); } } + + return head; } private static void SetCellAttributes(GridViewColumn column, HtmlGenericControl cell, bool isHeaderCell) @@ -493,7 +496,7 @@ protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequest base.AddAttributesToRender(writer, context); } - + public override IEnumerable GetLogicalChildren() {