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 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, Petar
First, I have to use .NET 3.5 for my project,
Second I found wat to workaround this issue.
Instead of
view = new Infragistics.Web.UI.DataSourceControls.DataView {ID = "Level" + i, DataSource = q};
You should write this (simply cast IQuerable q to List)
List<object> dynamicSource = Enumerable.Cast<object>(q).ToList(); view = new Infragistics.Web.UI.DataSourceControls.DataView {ID = "Level" + i, DataSource = dynamicSource};
With this change and InitialDataBindDepth of the grid set to "-1" islands are collapsed and expanded correctly.
BUT ! this means everything (all the data) is loaded to client at first load and extra memory is used to convert IQuerable to List.
Seems to be DataBind of mechanism of this grid doen't work correclty with IEnumerator<T> datasources, that doesn't support Reset() method. For example this RowNestedResultEnumerator enumerator which is returned for LINQ query result.
Is this behavior Intended or is it going to be fixed?
Apologies for the delayed response.
I have been researching the matter further and I believe that the matter is caused by a development issue of the hierarchical grid. The behavior you have been experiencing seems to occur only when attempting to expand rows whose data relation field values have multiple colons (here date fields use multiple colons for displaying the time). I have asked our engineering staff to examine this further. In order to ensure that the matter will receive attention I have logged this behavior in our internal tracking system with a Development ID 111363. The next step would be for a developer to research the issues and confirm my findings or offer some resolution.
Your support ticket number regarding this matter is CAS-89193-N4G11W . Please feel free to continue sending us updates. You can view the status of the development issue connected to this case by going to the “My IG” tab on our website, hovering to the "My Support Activity" dropdown and selecting the "Development Issues" tab.
Please let me know if you need more information.
Thanks a lot for your cooperation, Petar!
I'll look forward for new SR.
Hello Andrey,
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.
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
Regards,Andrey
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.