Hello,
I'm exprierencing strange behaviour of WHDG when grouped by DateTime column.
It either doesn't allow to expand grouped recods at all (in my case when groupped by CheckHed.ClearedDate) or expands only the first one and then doesn't expand others (WHDG expand only first expanded even when another row clicked to be expanded)
Page code is following
hDate.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="hDate.aspx.cs" Inherits="hDate" %><%@ Register TagPrefix="ig" Namespace="Infragistics.Web.UI.GridControls" Assembly="Infragistics35.Web.v10.3, Version=10.3.20103.2217, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="sm" runat="server"></asp:ScriptManager> <asp:UpdatePanel ID="HUP" ChildrenAsTriggers="true" runat="server"> <ContentTemplate> </ContentTemplate> </asp:UpdatePanel> </form></body></html>
hDate.aspx.cs
using System;using System.Collections.Generic;using System.Data;using System.Linq;using System.Linq.Dynamic;using System.Text;using System.Web.UI;using System.Web.UI.WebControls;using Infragistics.Web.UI.GridControls;public partial class hDate : System.Web.UI.Page{ private Infragistics.Web.UI.DataSourceControls.WebHierarchicalDataSource whds = new Infragistics.Web.UI.DataSourceControls.WebHierarchicalDataSource(); private WebHierarchicalDataGrid WHDG; protected override void CreateChildControls() { base.CreateChildControls(); #region WHDG this.WHDG = new WebHierarchicalDataGrid { ID = "WHDG", EnableViewState = true, EnableAjax = false, EnableDataViewState = false, EnableAjaxViewState = false, AutoGenerateBands = false, DataKeyFields = "k_0", AutoGenerateColumns = false }; if (WHDG.Behaviors.Selection == null) { Selection sel = WHDG.Behaviors.CreateBehavior<Selection>(); sel.Enabled = true; sel.AutoPostBackFlags.RowSelectionChanged = true; sel.RowSelectType = SelectType.Multiple; sel.CellSelectType = SelectType.None; sel.ColumnSelectType = SelectType.None; sel.CellClickAction = CellClickAction.Row; WHDG.Behaviors.Add(sel); } WHDG.Behaviors.Selection.Enabled = true; WHDG.Behaviors.Selection.AutoPostBackFlags.RowSelectionChanged = true; WHDG.Behaviors.Selection.RowSelectType = SelectType.Single; WHDG.Behaviors.Selection.CellSelectType = SelectType.None; WHDG.Behaviors.Selection.ColumnSelectType = SelectType.None; WHDG.Behaviors.Selection.CellClickAction = CellClickAction.Row; WHDG.Behaviors.Selection.CellSelectType = SelectType.None; WHDG.Behaviors.Selection.AutoPostBackFlags.RowSelectionChanged = true; if (this.WHDG.GridView.Behaviors.ColumnResizing == null) this.WHDG.GridView.Behaviors.Add(new ColumnResizing { Enabled = true }); this.WHDG.GridView.Behaviors.ColumnResizing.Enabled = true; this.HUP.ContentTemplateContainer.Controls.Add(this.WHDG); if (!Page.IsPostBack) { BoundDataField item = new BoundDataField { Key = "k_0" }; item.DataFieldName = "k_0"; item.Type = typeof(DateTime); item.Header.Text = "g1"; item.Width = Unit.Pixel(100); this.WHDG.Columns.Add(item); item = new BoundDataField { Key = "Count" }; item.DataFieldName = "Count"; item.Type = typeof(decimal); item.Header.Text = "Amount"; this.WHDG.Columns.Add(item); Band childBand, band; // Table childBand = new Band { //Key = "Level2", DataMember = "Level1", AutoGenerateColumns = true, DefaultColumnWidth = Unit.Pixel(100) }; this.WHDG.Bands.Add(childBand); band = childBand; band.Behaviors.Add(new ColumnResizing { Enabled = true }); band.Behaviors.Add(new Sorting { Enabled = true }); } #endregion } protected void Page_Load(object sender, EventArgs e) { this.EnsureChildControls(); #region WHDG band / column creation if (this.WHDG.Columns.Count == 0) { BoundDataField item = new BoundDataField { Key = "k_0" }; this.WHDG.Columns.Add(item); item.DataFieldName = "k_0"; item.Header.Text = "g1"; item.Width = Unit.Pixel(100); item = new BoundDataField { Key = "Count" }; this.WHDG.Columns.Add(item); item.DataFieldName = "Count"; item.Type = typeof(decimal); item.Header.Text = "Amount"; // Table Band childBand = new Band { DataMember = "Level2", AutoGenerateColumns = true, DefaultColumnWidth = Unit.Pixel(100) }; this.WHDG.Bands.Add(childBand); } #endregion this.FillHWDG(String.Empty); } private void FillHWDG(string filter) { DataSet ds = new DataSet(); ds.ReadXml("c:\\temp\\bad_date.xml", XmlReadMode.ReadSchema); this.CreateHierarchyDataSource(ds.Tables[0], new[] { "CheckHed.ClearedDate" }, filter); this.WHDG.DataSource = whds; } #region CreateHierarchyDataSource void CreateHierarchyDataSource(DataTable dataTable, string[] FieldsToGroupBy, string filter) { Infragistics.Web.UI.DataSourceControls.DataView view; Infragistics.Web.UI.DataSourceControls.DataRelation dr; List<string> parentColumns, childColumns; if (!String.IsNullOrEmpty(filter)) dataTable = new DataView(dataTable) { RowFilter = filter }.ToTable(); int j, i = 0, cnt = FieldsToGroupBy.Length; foreach (string GrouppingFieldName in FieldsToGroupBy) { StringBuilder groupByStatement = new StringBuilder("new ("); StringBuilder selectStatement = new StringBuilder("new ("); StringBuilder orderByStatement = new StringBuilder(); for (j = 0; j <= i; j++) { if (j > 0) { groupByStatement.Append(", "); selectStatement.Append(", "); orderByStatement.Append(", "); } groupByStatement.Append("it[\""); groupByStatement.Append(FieldsToGroupBy[j]); groupByStatement.Append("\"] as g_"); groupByStatement.Append(j.ToString()); selectStatement.Append("Key.g_"); selectStatement.Append(j.ToString()); selectStatement.Append(" as k_"); selectStatement.Append(j.ToString()); orderByStatement.Append("k_"); orderByStatement.Append(j.ToString()); } var q = (i + 1) < cnt ? dataTable.AsEnumerable().AsQueryable() .GroupBy(groupByStatement.AppendFormat(", it[\"{0}\"] as g_{1})", FieldsToGroupBy[j], j).ToString(), "it") .Select(selectStatement.AppendFormat(", Key.g_{0} as k_{0})", j).ToString()) .GroupBy("new (k_" + String.Join(", k_", Enumerable.Range(0, j).ToList().ConvertAll(x => x.ToString()).ToArray()) + ")", "it") .Select("new (Key.k_" + String.Join(", Key.k_", Enumerable.Range(0, j).ToList().ConvertAll(x => x.ToString()).ToArray()) + ", it.Count() as Count)") .OrderBy(orderByStatement.ToString(), null) : dataTable.AsEnumerable().AsQueryable() .GroupBy(groupByStatement.Append(")").ToString(), "it") .Select(selectStatement.Append(", it.Count() as Count)").ToString()) .OrderBy(orderByStatement.ToString(), null); view = new Infragistics.Web.UI.DataSourceControls.DataView(); view.ID = "Level" + i; view.DataSource = q; whds.DataViews.Add(view); if (i > 0) { dr = new Infragistics.Web.UI.DataSourceControls.DataRelation { ParentDataViewID = "Level" + (i - 1), ChildDataViewID = view.ID }; parentColumns = new List<string>(); childColumns = new List<string>(); for (j = 0; j < i; j++) { parentColumns.Add("k_" + j); childColumns.Add("k_" + j); } dr.ParentColumns = parentColumns.ToArray(); dr.ChildColumns = childColumns.ToArray(); whds.DataRelations.Add(dr); } i++; } // Last 'Data' view view = new Infragistics.Web.UI.DataSourceControls.DataView(); view.ID = "Level" + i; view.DataSource = dataTable; whds.DataViews.Add(view); if (i > 0) { dr = new Infragistics.Web.UI.DataSourceControls.DataRelation { ParentDataViewID = "Level" + (i - 1), ChildDataViewID = view.ID }; parentColumns = new List<string>(); childColumns = new List<string>(); for (j = 0; j < i; j++) { parentColumns.Add("k_" + j); childColumns.Add(FieldsToGroupBy[j]); } dr.ParentColumns = parentColumns.ToArray(); dr.ChildColumns = childColumns.ToArray(); whds.DataRelations.Add(dr); } } #endregion}
-----------------------------------------------------------------------------
xml with data is attached . You also need DynamicLinq (Dynamic.cs) to run this sample. It can be found in samples here http://msdn.microsoft.com/en-us/vstudio/bb894665.aspx for example.
You can change group by column easily here
this.CreateHierarchyDataSource(ds.Tables[0], new[] { "CheckHed.ClearedDate" }, filter);
I tried to group by CheckHed.CheckDate (only first time expand works OK, if you try to expand any other row, you will not be able to do this) and by CheckHed.ClearedDate (not expanded at all).
Grouping by any other column works without problems.
The way DataSource is created is the result of business case. Exact structure and depth of grouping is known only at Page_Load and data to display comes as DataSet.
My version of controls is 10.3.20103.2217
Can someone help?
Regards,
Andrey.
Hi Andrey,
Thank you for posting in the community.
I have investigated your scenario and while successfully replicating the behavior with the sample you have provided, the issue does not seem to be present when using any other datasource. As a possible approach to tackle this, I can suggest that you try using manual load on demand in order to access the respective records when grouping by your date columns.
Please feel free to contact me if you have any questions.
Hi, Petar
Is behavior I described intended?
What so special this (DLINQ) datasource has for DateTime columns that others do not?
Thank you for your reply.
I have been researching the matter further and I would suggest that you try setting the InitialDataBindDepth of the grid to "-1" as I was able to display the datasource grouped by DateTime with that setup. So far I am unable to determine why the child containers are not populated when using automatic load on demand, however it may be considering manual load on demand in this scenario.
Please let me know if this is helpful.
Thank you, Petar
I tried your approach with InitialDataBindDepth = -1. It realy works in my case but only with one level of groupping and there's another issue arise.
When I have 2 GroupBy levels collapse / expand buttons simply dissapear for all rows except first and expanded Rows' amount (not aggregated count, but table rows show in nested row island) doesn't correspond real data, when InitialDataBindDepth is set to -1 (these buttons become visible right after InitialDataBindDepth = -1 is removed from controls initialization).
This behavior can be reproduced using my sample. Here is modified code for hDate.aspx.cs file
Regards,Andrey
I have been researching the sample you provided but am still unable to isolate the cause of the row island population. From your sample code I can see that the grid's ViewState is enabled in this case which may cause issues, so it may be worth turning it off. At this point I can suggest handling the RowIslandPopulating and populating the child bands manually:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.2/CLR4.0/?page=WebHierarchicalDataGrid_Load_On_Demand.html
Let me know if you need more information.
Hello Andrey,
Please note that the research on issue 117317 is still ongoing and it will most likely not be resolved in the upcoming SR scheduled for the end of this month. I will keep you informed of our engineer's findings regarding this matter.
Thanks, Petar
I'll look forward for new SR.
Just an update to inform you that the issues present when grouping by date column with dynamic LINQ have been logged in issue 117317.
I will keep you posted of any additional information regarding this matter as it becomes available.
Please feel free to contact me with any updates or questions in the meantime.
The fix for issue 111363 is included in the latest service releases for volumes 11.1, 11.2 and 12.1. Please feel free to contact me if you experience any issues after upgrading to the latest SR.
Thanks a lot for your cooperation, Petar!