Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / WebHierarchicalDataGrid samples using datasets/datatables from code-behind
WebHierarchicalDataGrid samples using datasets/datatables from code-behind
New DiscussionHow many levels of nested data could be displayed using WebHierarchicalDataGrid? We need to display 4 levels. Does this control support?
All samples provided are using WebHierarchicalDataSource control for the source. How does WHDG work using WHDS? Does it get data for all childrens during the initial page load and then filters at the client-side using data relations?
Are there any samples that shows how to achieve the same hierarchy using datasets/datatables in code-behind?
I would appreciate your response on this!
Replies
-
0Hello Ram,It is not a problem to display 4 levels using the webhierarchicaldatagrid, you should just assign a datasource with 4 levels to it.The number of levels that are loaded on a initial load can be defined with the property InitialDataBindDepth. By default, the value for this property is 0, which means that only the parent band is loaded. When a row is expanded, a partial postback loads the child rows for the current row.The webhierarchicaldatagrid in it, is bound to a two levels dataset. If you would like a 4 levels one, you should just configure the dataset to be with 4 levels (by putting proper datarelations to it).Hope this helps.Regards,LyubaDeveloper Support EngineerInfragistics
-
0
Hey Lyuba,
Thank you for your response.
However, I don't see any load-on-demand happening at the child level with your sample code. The data for the child level is retrieved and loaded into the dataset along with the parent data.
This would definitely perform bad when the data at the lower levels are huge. In my case, I have 4 levels of hierarchy. The total records at the 4 level could run into thousands to millions. I would like to get data for the lower level only when the parent row is expanded using code-behind architecture. How do I achieve this?
I appreciate your response!
Thanks
-
0
Hello Lyuba,
How would that work where there are no fixed levels. One of the parents has children 5 levels deep and the other has 9.
In my scenario, I might be looking at 17 levels deep for a few parents.
The examples in the help section use Access/SQL DataSource, which I cannot in my case.
I have the data in a single dataset, I've attached a screenshot of the table. It's flat and the key is on 'EVENT_ID,LOGICAL_NAME,LOGICAL_PARENT_NAME'. The table shows only until level 2, but down the line there will be more than 15 levels.
What is the best way for me to use this in memory data set and create self reference and display the names of servers in a hierarchical tree structure?
this is on VS 2008 ASP.NET || Infragistics35.Web.v10.1|| VB.NET || ORACLE
Thanks,
-
0
Lyuba,
I followed your steps to create the webhierarchical grid, but I cannot see the arrows for the top level rows. I am not sure why? Can you please help me. I am using the assembly "Infragistics35.Web.v9.2, Version=9.2.20092.1003".
Here is my aspx code:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<ig:WebHierarchicalDataGrid DataKeyFields="FinStmtGroup"
ID="WebHierarchicalDataGrid1"
runat="server"
Height="350px"
Width="90%"
OnInitializeRow="WebHierarchicalDataGrid1_InitializeRow"
OnPreRender="WebHierarchicalDataGrid1_PreRender"
OnRowIslandsPopulating="WebHierarchicalDataGrid1_RowIslandsPopulating"
>
</ig:WebHierarchicalDataGrid>And here is my aspx.vb file code:
Protected Sub WebHierarchicalDataGrid1_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.Web.UI.GridControls.RowEventArgs) Handles WebHierarchicalDataGrid1.InitializeRow
' don't show the arrow for the last level
If DirectCast(e.Row, ContainerGridRecord).Level < 2 Then
DirectCast(e.Row, ContainerGridRecord).IsEmptyParent = True
End If
End SubProtected Sub WebHierarchicalDataGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles WebHierarchicalDataGrid1.PreRender
If Not IsPostBack Then
For Each row As ContainerGridRecord In WebHierarchicalDataGrid1.GridView.Rows
row.IsEmptyParent = True
Next
End If
End SubProtected Sub WebHierarchicalDataGrid1_RowIslandsPopulating(ByVal sender As Object, ByVal e As Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs) Handles WebHierarchicalDataGrid1.RowIslandsPopulating
'Cancel the default automatic load on demand operation
e.Cancel = True
Select Case e.Row.Level
Case 0
BindSecondLevel(e)
Exit Select
Case 1
BindThirdLevel(e)
Exit Select
End Select
End SubPrivate Sub BindGrid()
Dim Conn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("").ConnectionString)
Dim Cmd As SqlCommand = New SqlCommand()
Cmd.Connection = Conn
Dim paramBrID As SqlParameter = New SqlParameter
Dim paramStratDt As SqlParameter = New SqlParameter
Dim parmStopDt As SqlParameter = New SqlParameter
Dim paramFinStmtGroup As SqlParameter = New SqlParameter
Dim paramLoanNo As SqlParameter = New SqlParameter
Dim paramLoanOfficer As SqlParameter = New SqlParameter
Dim paramVendor As SqlParameter = New SqlParameter
Dim paramGridLevel As SqlParameter = New SqlParameterTry
Conn.Open()
Cmd.CommandText = "dbo.SelectAMBTransactionsProc"
Cmd.CommandType = CommandType.StoredProcedureWith paramBrID
.ParameterName = "@BrID"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.Int
End With
'paramBrID.Value = Session("BrID")
paramBrID.Value = 1
Cmd.Parameters.Add(paramBrID)With paramStratDt
.ParameterName = "@StartDt"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.DateTime
End With
paramStratDt.Value = "01/01/2010"
Cmd.Parameters.Add(paramStratDt)With parmStopDt
.ParameterName = "@StopDt"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.DateTime
End With
parmStopDt.Value = "09/01/2010"
Cmd.Parameters.Add(parmStopDt)With paramFinStmtGroup
.ParameterName = "@FinStmtGroup"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.VarChar
End With
paramFinStmtGroup.Value = "ALL"
Cmd.Parameters.Add(paramFinStmtGroup)With paramLoanNo
.ParameterName = "@LoanNo"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.VarChar
End With
paramLoanNo.Value = DBNull.Value
Cmd.Parameters.Add(paramLoanNo)With paramLoanOfficer
.ParameterName = "@LoanOfficer"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.VarChar
End With
paramLoanOfficer.Value = "ALL"
Cmd.Parameters.Add(paramLoanOfficer)With paramVendor
.ParameterName = "@vendor"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.VarChar
End With
paramVendor.Value = "Roger"
Cmd.Parameters.Add(paramVendor)With paramGridLevel
.ParameterName = "@GridLevel"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.SmallInt
End With
paramGridLevel.Value = 1
Cmd.Parameters.Add(paramGridLevel)Dim _DataSet As New DataSet()
Dim _DataAdapter As SqlDataAdapter_DataAdapter = New SqlDataAdapter(Cmd)
_DataAdapter.Fill(_DataSet, "FirstLevelDataTable")
WebHierarchicalDataGrid1.DataSource = _DataSet
WebHierarchicalDataGrid1.DataBind()
Catch ex As ExceptionEnd Try
End SubPrivate Sub BindSecondLevel(ByVal e As Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs)
' Get the data key
Dim _FinStmtGroup As String = e.Row.DataKey(0)Dim Conn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("").ConnectionString)
Dim Cmd As SqlCommand = New SqlCommand()
Cmd.Connection = Conn
Dim paramBrID As SqlParameter = New SqlParameter
Dim paramStratDt As SqlParameter = New SqlParameter
Dim parmStopDt As SqlParameter = New SqlParameter
Dim paramFinStmtGroup As SqlParameter = New SqlParameter
Dim paramLoanNo As SqlParameter = New SqlParameter
Dim paramLoanOfficer As SqlParameter = New SqlParameter
Dim paramVendor As SqlParameter = New SqlParameter
Dim paramGridLevel As SqlParameter = New SqlParameterConn.Open()
Cmd.CommandText = "dbo.SelectAMBTransactionsProc"
Cmd.CommandType = CommandType.StoredProcedureWith paramBrID
.ParameterName = "@BrID"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.Int
End With
'paramBrID.Value = Session("BrID")
paramBrID.Value = 1
Cmd.Parameters.Add(paramBrID)With paramStratDt
.ParameterName = "@StartDt"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.DateTime
End With
paramStratDt.Value = "01/01/2010"
Cmd.Parameters.Add(paramStratDt)With parmStopDt
.ParameterName = "@StopDt"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.DateTime
End With
parmStopDt.Value = "09/01/2010"
Cmd.Parameters.Add(parmStopDt)With paramFinStmtGroup
.ParameterName = "@FinStmtGroup"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.VarChar
End With
paramFinStmtGroup.Value = _FinStmtGroup
Cmd.Parameters.Add(paramFinStmtGroup)With paramLoanNo
.ParameterName = "@LoanNo"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.VarChar
End With
paramLoanNo.Value = "All"
Cmd.Parameters.Add(paramLoanNo)With paramLoanOfficer
.ParameterName = "@LoanOfficer"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.VarChar
End With
paramLoanOfficer.Value = DBNull.Value
Cmd.Parameters.Add(paramLoanOfficer)With paramVendor
.ParameterName = "@vendor"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.VarChar
End With
paramVendor.Value = "Roger"
Cmd.Parameters.Add(paramVendor)With paramGridLevel
.ParameterName = "@GridLevel"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.SmallInt
End With
paramGridLevel.Value = 2
Cmd.Parameters.Add(paramGridLevel)Dim _DataSet As New DataSet()
Dim _DataAdapter As SqlDataAdapter_DataAdapter = New SqlDataAdapter(Cmd)
_DataAdapter.Fill(_DataSet, "SecondLevelDataTable")' Create Container Grid
Dim childGrid As New ContainerGrid()
e.Row.RowIslands.Add(childGrid)' Bind Grid
childGrid.DataKeyFields = "FinStmtGroup"
childGrid.Level = 1
childGrid.DataSource = _DataSet
childGrid.DataBind()End Sub
Private Sub BindThirdLevel(ByVal e As Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs)
' Get the data key
Dim _FinStmtGroup As String = e.Row.DataKey(0)Dim Conn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("").ConnectionString)
Dim Cmd As SqlCommand = New SqlCommand()
Cmd.Connection = Conn
Dim paramBrID As SqlParameter = New SqlParameter
Dim paramStratDt As SqlParameter = New SqlParameter
Dim parmStopDt As SqlParameter = New SqlParameter
Dim paramFinStmtGroup As SqlParameter = New SqlParameter
Dim paramLoanNo As SqlParameter = New SqlParameter
Dim paramLoanOfficer As SqlParameter = New SqlParameter
Dim paramVendor As SqlParameter = New SqlParameter
Dim paramGridLevel As SqlParameter = New SqlParameterConn.Open()
Cmd.CommandText = "dbo.SelectAMBTransactionsProc"
Cmd.CommandType = CommandType.StoredProcedureWith paramBrID
.ParameterName = "@BrID"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.Int
End With
'paramBrID.Value = Session("BrID")
paramBrID.Value = 1
Cmd.Parameters.Add(paramBrID)With paramStratDt
.ParameterName = "@StartDt"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.DateTime
End With
paramStratDt.Value = "01/01/2010"
Cmd.Parameters.Add(paramStratDt)With parmStopDt
.ParameterName = "@StopDt"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.DateTime
End With
parmStopDt.Value = "09/01/2010"
Cmd.Parameters.Add(parmStopDt)With paramFinStmtGroup
.ParameterName = "@FinStmtGroup"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.VarChar
End With
paramFinStmtGroup.Value = _FinStmtGroup
Cmd.Parameters.Add(paramFinStmtGroup)With paramLoanNo
.ParameterName = "@LoanNo"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.VarChar
End With
paramLoanNo.Value = "All"
Cmd.Parameters.Add(paramLoanNo)With paramLoanOfficer
.ParameterName = "@LoanOfficer"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.VarChar
End With
paramLoanOfficer.Value = DBNull.Value
Cmd.Parameters.Add(paramLoanOfficer)With paramVendor
.ParameterName = "@vendor"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.VarChar
End With
paramVendor.Value = "Roger"
Cmd.Parameters.Add(paramVendor)With paramGridLevel
.ParameterName = "@GridLevel"
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.SmallInt
End With
paramGridLevel.Value = 3
Cmd.Parameters.Add(paramGridLevel)Dim _DataSet As New DataSet()
Dim _DataAdapter As SqlDataAdapter_DataAdapter = New SqlDataAdapter(Cmd)
_DataAdapter.Fill(_DataSet, "ThirdLevelDataTable")' Create Container Grid
Dim childGrid As New ContainerGrid()
e.Row.RowIslands.Add(childGrid)' Bind Grid
childGrid.DataKeyFields = "FinStmtGroup"
childGrid.Level = 2
childGrid.DataSource = _DataSet
childGrid.DataBind()End Sub
-
-
0
-
0
Hey Lyuba,
I see a problem. The arrow for the user to expand at the parent level is visible only when I bind the child level data. That means, I have to bind all the 4 levels in order to override the RowIslandsPopulating event.
How can I display the arrow at the parent level by not binding the child levels so that I can manually perform load on demand for the childrens?
I would appreciate your response!
Thanks
-
-
0Hello Ram,I think that the automatic load on demand would fit your 4 levels scenario. In order to implemented it, you should just set the InitialDataBindDepth to 0. Then you can bind your grid either at design time or at runtime, by providing the datasource every time in page load. The first time the grid will load just the parent band, and when a row is expanded the proper level will be loaded from the datasource.But in case you still want to implement the manual load on demand option, I have created a sample project that shows the proper way to achieve it.There, you can see how the arrow is shown (with the help of IsEmptyParent property). My sample is with a webhierarchicaldatagrid that has 3 levels, but it is not hard to add a fourth level to it.Hope this helps.Lyuba PetrovaDeveloper Support EngineerInfragistics
-
0
Thank you Lyuba for providing the sample.
I was able to dynamically add data bound fields to the childGrid and change the header text.
childGrid.AutoGenerateColumns = false;
BoundDataField bdf1 = new BoundDataField(true);
bdf1.DataFieldName = "ProductID";
bdf1.Header.Text = "Product ID";
bdf1.Key = "ProductID";
childGrid.Columns.Add(bdf1);BoundDataField bdf2 = new BoundDataField(true);
bdf2.DataFieldName = "ProductName";
bdf2.Header.Text = "Product Name";
bdf2.Key = "ProductName";
childGrid.Columns.Add(bdf2);However, I am unable to set the columns as sortable. Could you please provide a sample code for the same?
SortingColumnSetting scs1 = new SortingColumnSetting();
scs1.ColumnKey = "ProductID";
scs1.Sortable = true;
childGrid.Behaviors.Sorting.ColumnSettings.Add(scs1);This doesn't work.
-
0
Lyuba,
That sample for manual load on demand uses a generic list as a datasource for the grid. If I change the datasource to dataset – arrows do not appear on the top level. Any idea why? I need this approach to work with dataset, as it returns variable number of columns (depending on the query) and I cannot attach a hard-coded class to it.
-
0
Hi,
I created a similar example based on the on demand example shared in this thread up to 6 levels and it working perfectly. But I need to add calculated footer values to every level.
Trying to access the Footer object I got null exception. Please help me to resolve this.
Here is my code…..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using Infragistics.Web.UI.GridControls;
using dbTask;public partial class InfraReports_BalanceSheetRep : System.Web.UI.Page
{private string _connStr = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (txtFrom.Text.ToString() == "") { txtFrom.Text = "01/01/" + Convert.ToString(DateTime.Now.Year); }
if (txtTo.Text.ToString() == "") { txtTo.Text = "06/30/2017"; }
BindGrid();
}protected void WHDG_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
{
// don't show the arrow for the last level
if (((ContainerGridRecord)e.Row).Level < 5)
((ContainerGridRecord)e.Row).IsEmptyParent = true;
}
protected void WHDG_RowIslandsPopulating(object sender, Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs e)
{
//Cancel the default automatic load on demand operation
e.Cancel = true;
switch (e.Row.Level)
{
case 0:
BindSecondLevel(e);
break;
case 1:
BindThirdLevel(e);
break;
case 2:
case 3:
case 4:
BindFourthLevel(e.Row.Level, e);
break;
}}
protected void WHDG_PreRender(object sender, EventArgs e)
{
if (!IsPostBack)
{
foreach (ContainerGridRecord row in WHDG.GridView.Rows)
{
row.IsEmptyParent = true;
}
}
}private void BindGrid()
{
DataSet dsData = new DataSet();
BalanceSheetRepository bs = new BalanceSheetRepository();
dsData = bs.GetDataByLevel(1, "0", txtFrom.Text.ToString(), txtTo.Text.ToString());
WHDG.AutoGenerateColumns = true;
WHDG.ShowFooter = true;WHDG.DataSource = dsData;
WHDG.DataBind();// this.WHDG.GridView.Columns[0].Footer.Text = "Sample footer text";
}private void BindSecondLevel(Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs e)
{
// Get the data key
String key = e.Row.DataKey[0].ToString();
DataSet dsData = new DataSet();
BalanceSheetRepository bs = new BalanceSheetRepository();
dsData = bs.GetDataByLevel(2, key, txtFrom.Text.ToString(), txtTo.Text.ToString());// Create Container Grid
ContainerGrid childGrid = new ContainerGrid();
e.Row.RowIslands.Add(childGrid);// Bind Grid
childGrid.DataKeyFields = "AccountTypeId";
childGrid.ShowFooter = true;
childGrid.Level = 1;
childGrid.DataSource = dsData;
childGrid.DataBind();
}private void BindThirdLevel(Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs e)
{
// Get the data key
String key = e.Row.DataKey[0].ToString();DataSet dsData = new DataSet();
BalanceSheetRepository bs = new BalanceSheetRepository();
dsData = bs.GetDataByLevel(3, key, txtFrom.Text.ToString(), txtTo.Text.ToString());// Create Container Grid
ContainerGrid childGrid = new ContainerGrid();
e.Row.RowIslands.Add(childGrid);// Bind Grid
childGrid.DataKeyFields = "ScheduleId";
childGrid.Level = 2;
childGrid.DataSource = dsData;
childGrid.DataBind();
}private void BindFourthLevel(int level, Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs e)
{
// Get the data key
String key = e.Row.DataKey[0].ToString();DataSet dsData = new DataSet();
BalanceSheetRepository bs = new BalanceSheetRepository();
dsData = bs.GetDataByLevel((level + 2), key, txtFrom.Text.ToString(), txtTo.Text.ToString());// Create Container Grid
ContainerGrid childGrid = new ContainerGrid();
e.Row.RowIslands.Add(childGrid);// Bind Grid
if (level == 2) {
childGrid.DataKeyFields = "AccountId";
childGrid.Level = 3;
}
else if (level == 3){
childGrid.DataKeyFields = "LedgerId";
childGrid.Level = 4;
}
else if (level == 4)
{
childGrid.DataKeyFields = "LedgerId";
childGrid.Level = 5;
}
childGrid.DataSource = dsData;
childGrid.DataBind();}
protected void WHDG_DataBound(object sender, EventArgs e)
{
double total = 0;
foreach (ContainerGridRecord row in this.WHDG.GridView.Rows)
{
total += Convert.ToDouble(row.Items[2].Text.Trim());
}
// this.WHDG.GridView.Columns[0].Footer.Text = total.ToString();
// this.WHDG.GridView.Band.Bands[0].Bands[0].Columns["Balance"].Footer.Text = total.ToString();}
protected void WHDG_RowIslandsPopulated(object sender, ContainerRowEventArgs e)
{
e.Row.RowIslands[0].Columns[0].Footer.Text = "Sample footer text";
e.Row.RowIslands[0].ShowFooter = true;
}
}
-
-
0Hello Ram,If you want to have sorting for the webhierarchicaldatagrid, you should do it by using the Sorting behavior. Here you can find samples for enabling this behavior for the parent band and for the child bands:https://www.infragistics.com/samples/aspnet/hierarchical-data-grid/sorting-child-band (WebHierarchicalDataGrid -> Sorting – On Child Band Level | Sorting – On Parent Band Level).If you create your child bands in the source code you can enable the sporting behavior like this:childGrid.Behaviors.CreateBehavior<Sorting>();childGrid.Behaviors.Sorting.Enabled = true;By enabling this behavior, by default, all columns will be sortable. If you want to restrict some columns from sorting, you can use the SortingColumnSetting class:SortingColumnSetting sett = new SortingColumnSetting();sett.ColumnKey = "ProductID";sett.Sortable = false;childGrid.Behaviors.Sorting.ColumnSettings.Add(sett);Regards,Lyuba PetrovaDeveloper Support EngineerInfragistics
-
0
Hey Lyuba,
I am getting the error "Runtime Exception: [object Error]" on adding the code to enable sorting at child band level.
childGrid.Behaviors.CreateBehavior<Sorting>();
childGrid.Behaviors.Sorting.Enabled = true;SortingColumnSetting scs2 = new SortingColumnSetting();
scs2.ColumnKey = "ProductName";
scs2.Sortable = false;
childGrid.Behaviors.Sorting.ColumnSettings.Add(scs2); -
0
Hi, I am unable to set the columns as sortable. Could you please provide a sample code for the same?
My Excel style filtering is also not working for child Grids (But sort and filtering is working perfectly for the first parent grid)
Please give me some suggestion or a sample code.
My code as follows
private void BindSecondLevel(Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs e)
{
String key = e.Row.DataKey[0].ToString();
txtYear.Text = e.Row.Items[0].Text.ToString();
DataSet dsData = new DataSet();
CmsBusinessRepository bs = new CmsBusinessRepository();
dsData = bs.GetInvoiceDataByLevel(2, key, txtFrom.Text.ToString(), txtTo.Text.ToString(), "0", Datetype);ContainerGrid childGrid = new ContainerGrid();
e.Row.RowIslands.Add(childGrid);childGrid.DataKeyFields = "CustomerId";
childGrid.AutoGenerateColumns = false;
childGrid.Level = 1;
childGrid.DataSource = dsData;
childGrid.Key = "CustomerSummary";childGrid.Behaviors.CreateBehavior<Sorting>();
childGrid.Behaviors.Sorting.Enabled = true;SortingColumnSetting scs2 = new SortingColumnSetting();
scs2.ColumnKey = "Tax";
scs2.Sortable = false;
childGrid.Behaviors.Sorting.ColumnSettings.Add(scs2);childGrid.Behaviors.CreateBehavior<Filtering>();
childGrid.Behaviors.Filtering.Enabled = true;
childGrid.Behaviors.Filtering.ApplyFilter();BoundDataField CustomerId = new BoundDataField();
CustomerId.DataFieldName = "CustomerId";
CustomerId.Key = "CustomerId";
CustomerId.Header.Text = "ID";
CustomerId.Header.CssClass = "igg_HeaderNumericLevelTwo";
CustomerId.Width = Unit.Percentage(2.5);
CustomerId.CssClass = "igMainCellsAlignLeft";
childGrid.Columns.Add(CustomerId);BoundDataField Customer = new BoundDataField();
Customer.DataFieldName = "Customer";
Customer.Key = "Customer";
Customer.Header.Text = "CUSTOMER";
Customer.Header.CssClass = "igg_HeaderNumericLevelTwo";
Customer.Width = Unit.Percentage(10);
Customer.CssClass = "igMainCellsAlignLeft";
childGrid.Columns.Add(Customer);BoundDataField Subtotal = new BoundDataField();
Subtotal.DataFieldName = "Subtotal";
Subtotal.Key = "Subtotal";
Subtotal.Header.Text = "MERCH-PRICE";
Subtotal.Header.CssClass = "igg_HeaderNumericLevelTwo";
Subtotal.Width = Unit.Percentage(6);
Subtotal.DataFormatString = "{0:c2}";
Subtotal.CssClass = "igCellsAlignRight";
childGrid.Columns.Add(Subtotal);BoundDataField FreightCharge = new BoundDataField();
FreightCharge.DataFieldName = "FreightCharge";
FreightCharge.Key = "FreightCharge";
FreightCharge.Header.Text = "FREIGHT CHARGE";
FreightCharge.Header.CssClass = "igg_HeaderNumericLevelTwo";
FreightCharge.Width = Unit.Percentage(6);
FreightCharge.DataFormatString = "{0:c2}";
FreightCharge.CssClass = "igCellsAlignRight";
childGrid.Columns.Add(FreightCharge);BoundDataField Tax = new BoundDataField();
Tax.DataFieldName = "Tax";
Tax.Key = "Tax";
Tax.Header.Text = "TAX";
Tax.Header.CssClass = "igg_HeaderNumericLevelTwo";
Tax.Width = Unit.Percentage(5);
Tax.DataFormatString = "{0:c2}";
Tax.CssClass = "igCellsAlignRight";
childGrid.Columns.Add(Tax);BoundDataField MiscellaneousCharge = new BoundDataField();
MiscellaneousCharge.DataFieldName = "MiscellaneousCharge";
MiscellaneousCharge.Key = "MiscellaneousCharge";
MiscellaneousCharge.Header.Text = "MISC CHARGES";
MiscellaneousCharge.Header.CssClass = "igg_HeaderNumericLevelTwo";
MiscellaneousCharge.Width = Unit.Percentage(7);
MiscellaneousCharge.DataFormatString = "{0:c2}";
MiscellaneousCharge.CssClass = "igCellsAlignRight";
childGrid.Columns.Add(MiscellaneousCharge);BoundDataField Discount = new BoundDataField();
Discount.DataFieldName = "Discount";
Discount.Key = "Discount";
Discount.Header.Text = "DISCOUNT";
Discount.Header.CssClass = "igg_HeaderNumericLevelTwo";
Discount.Width = Unit.Percentage(6);
Discount.DataFormatString = "{0:c2}";
Discount.CssClass = "igCellsAlignRight";
childGrid.Columns.Add(Discount);BoundDataField Totalamount = new BoundDataField();
Totalamount.DataFieldName = "Totalamount";
Totalamount.Key = "Totalamount";
Totalamount.Header.Text = "TOTAL AMOUNT";
Totalamount.Header.CssClass = "igg_HeaderNumericLevelTwo";
Totalamount.Width = Unit.Percentage(7);
Totalamount.DataFormatString = "{0:c2}";
Totalamount.CssClass = "igCellsAlignRight";
childGrid.Columns.Add(Totalamount);BoundDataField CreditMemo = new BoundDataField();
CreditMemo.DataFieldName = "CreditMemo";
CreditMemo.Key = "CreditMemo";
CreditMemo.Header.Text = "CREDIT MEMO";
CreditMemo.Header.CssClass = "igg_HeaderNumericLevelTwo";
CreditMemo.Footer.CssClass = "igg_Footer";
CreditMemo.Width = Unit.Percentage(7);
CreditMemo.DataFormatString = "{0:c2}";
CreditMemo.CssClass = "igCellsAlignRight";
childGrid.Columns.Add(CreditMemo);BoundDataField DebitMemo = new BoundDataField();
DebitMemo.DataFieldName = "DebitMemo";
DebitMemo.Key = "DebitMemo";
DebitMemo.Header.Text = "DEBIT MEMO";
DebitMemo.Header.CssClass = "igg_HeaderNumericLevelTwo";
DebitMemo.Footer.CssClass = "igg_Footer";
DebitMemo.Width = Unit.Percentage(7);
DebitMemo.DataFormatString = "{0:c2}";
DebitMemo.CssClass = "igCellsAlignRight";
childGrid.Columns.Add(DebitMemo);BoundDataField SUBTOTALCOST = new BoundDataField();
SUBTOTALCOST.DataFieldName = "Subtotalcost";
SUBTOTALCOST.Key = "Subtotalcost";
SUBTOTALCOST.Header.Text = "SUBTOTAL COST";
SUBTOTALCOST.Header.CssClass = "igg_HeaderNumericLevelTwo";
SUBTOTALCOST.Footer.CssClass = "igg_Footer";
SUBTOTALCOST.Width = Unit.Percentage(7);
SUBTOTALCOST.DataFormatString = "{0:c2}";
SUBTOTALCOST.CssClass = "igCellsAlignRight";
childGrid.Columns.Add(SUBTOTALCOST);BoundDataField DUTY_COST = new BoundDataField();
DUTY_COST.DataFieldName = "DUTYCOST";
DUTY_COST.Key = "DUTYCOST";
DUTY_COST.Header.Text = "DUTY COST";
DUTY_COST.Header.CssClass = "igg_HeaderNumericLevelTwo";
DUTY_COST.Footer.CssClass = "igg_Footer";
DUTY_COST.Width = Unit.Percentage(6);
DUTY_COST.DataFormatString = "{0:c2}";
DUTY_COST.CssClass = "igCellsAlignRight";
childGrid.Columns.Add(DUTY_COST);BoundDataField TOTAL_FREIGHT_COST = new BoundDataField();
TOTAL_FREIGHT_COST.DataFieldName = "TOTALFREIGHTCOST";
TOTAL_FREIGHT_COST.Key = "TOTALFREIGHTCOST";
TOTAL_FREIGHT_COST.Header.Text = "TOTAL FREIGHT COST";
TOTAL_FREIGHT_COST.Header.CssClass = "igg_HeaderNumericLevelTwo";
TOTAL_FREIGHT_COST.Footer.CssClass = "igg_Footer";
TOTAL_FREIGHT_COST.Width = Unit.Percentage(7);
TOTAL_FREIGHT_COST.DataFormatString = "{0:c2}";
TOTAL_FREIGHT_COST.CssClass = "igCellsAlignRight";
childGrid.Columns.Add(TOTAL_FREIGHT_COST);BoundDataField PROFIT = new BoundDataField();
PROFIT.DataFieldName = "PROFIT";
PROFIT.Key = "PROFIT";
PROFIT.Header.Text = "PROFIT";
PROFIT.Header.CssClass = "igg_HeaderNumericLevelTwo";
PROFIT.Footer.CssClass = "igg_Footer";
PROFIT.Width = Unit.Percentage(5);
PROFIT.DataFormatString = "{0:c2}";
PROFIT.CssClass = "igCellsAlignRight";
childGrid.Columns.Add(PROFIT);BoundDataField PROFIT_PER = new BoundDataField();
PROFIT_PER.DataFieldName = "PROFITPER";
PROFIT_PER.Key = "PROFITPER";
PROFIT_PER.Header.Text = "PROFIT-%";
PROFIT_PER.Header.CssClass = "igg_HeaderNumericLevelTwo";
PROFIT_PER.Footer.CssClass = "igg_Footer";
PROFIT_PER.Width = Unit.Percentage(4);
PROFIT_PER.DataFormatString = "{0:N2}";
PROFIT_PER.CssClass = "igCellsAlignRight";
childGrid.Columns.Add(PROFIT_PER);childGrid.DataBind();
}
Regards,
Mohandas Pk
-
0
Mohandas,
I recommend starting a new thread for your issue with a sample that reproduces the issue. I did look at your code and see that you are adding the sorting behavior to the child band though none of your markup is included or the definition of the parent columns. Some things that come to mind that could cause behaviors to fail in general:
- DataKeyFields aren't set correctly so the children aren't found.
- As the behavior is added dynamically, it needs to be added on every call to the server and for this it would be better to set up the behaviors in markup.
Let me know if you have any questions with this matter.
-
0
Hi,
Here is my markup.
<div>
<ig:WebHierarchicalDataGrid ID="WHDG" runat="server" Height="800px" Width="100%" DataKeyFields="Year" ShowFooter="True"
oninitializerow="WHDG_InitializeRow"
onprerender="WHDG_PreRender"
onrowislandspopulating="WHDG_RowIslandsPopulating" OnDataBound="WHDG_DataBound" OnInitializeBand="WHDG_InitializeBand" OnRowIslandDataBinding="WHDG_RowIslandDataBinding" >
<Behaviors>
<ig:ColumnResizing EnableInheritance="True">
</ig:ColumnResizing>
<ig:Sorting EnableInheritance="True">
</ig:Sorting>
<ig:Activation>
</ig:Activation>
<ig:Filtering EnableInheritance="True" FilterType="ExcelStyleFilter">
</ig:Filtering>
</Behaviors></ig:WebHierarchicalDataGrid>
</div>
Here I enabled sorting with inheritance , but it works only in parent grid, All child grids are generated dynamically.
Every thing is working fine with out sorting and filtering.
-
0
Mohandas,
Please provide a sample that replicates how you are setting up the grid in your application that I can run and debug to find out what is happening. There is relevant logic that isn't included in the code that you have already provided and this will allow me to help you faster.
Let me know if you have any questions with this matter.
-
0
Hi,
Please check the sample code from this link
https://drive.google.com/open?id=0B6oOTBj9qI4cek5lVFJtazZuUTQ
This sample contains a Web Hierarchical Grid, it populated dynamically on demand.
The parent grid with state data working perfectly, it allows me to sort and filter.
But sorting and filtering is not working in the child grid.Please check it .
-
0
Hello Mohandas,
Firstly I want to inform you that, questions like this one should be tracked as a new forum thread. It would be better for both sides, for you and for us.
It will be better for you, because you will be able to track this case easily and follow every status and updates on it. For us it will be tracked as separate problem, which will be very convenient, fastly handled and easily traced.
Аs far as the problem I made an isolated working sample, which works perfect.
I noticed that, you don't set properly your dataKeyFields to the grid, which is very important for every action like (filtering, sorting, editing, etc…).
Also, I didn't notice any data relation between your parent and child grid.
And one more thing that I've noticed is that, on every RowIslandsPopulationg, you rebind your child grid with the data which is not filtered(you directly accessing the data from you data repository, which is not new filtered data), this is another problem why you can't see your filtered data.
Please refer to my attachment and try to refactor your approach.
If you need further assistance or additional questions, please feel free to contact us.
-
-
-
0Hi Ram,You should enable the sorting behavior for the webhierarchicaldatagrid itself:<ig:WebHierarchicalDataGrid DataKeyFields="CategoryID" ID="WebHierarchicalDataGrid1" runat="server" Height="350px"Width="100%" oninitializerow="WebHierarchicalDataGrid1_InitializeRow"onprerender="WebHierarchicalDataGrid1_PreRender"onrowislandspopulating="WebHierarchicalDataGrid1_RowIslandsPopulating"><Behaviors><ig:Sorting Enabled="true"></ig:Sorting></Behaviors></ig:WebHierarchicalDataGrid>LyubaDeveloper Support EngineerInfragistics
-
0Hello Natraj,I think that would work in your scenario.If you take a look at the sample that I attached you will see that I am defining of a row has children by assigning its IsRowParent property. In your scenario, you can just implement some custom logic that says if a row has a children and, if not you just don’t set this property to true. Here is an example:// indentify if the row has children – in my example if the first cell contains even numberbool isEven = (Int32.Parse(e.Row.Items[0].Text) % 2) == 0;if (isEven)((ContainerGridRecord)e.Row).IsEmptyParent = true;Lyuba PetrovaDeveloper Support EngineerInfragistics
-
0
I created a similar example based on the on demand example shared in this thread. But I am getting strange error while expanding the nodes.
public
partial class CustomWebHierarchicalGrid : System.Web.UI.
Page
{
public void whdg1_PreRender(object sender, EventArgs
e)
{
if
(!IsPostBack)
{
foreach (ContainerGridRecord row in
whdg1.GridView.Rows)
{
row.IsEmptyParent =
true
;
}
}
}
public void whdg1_InitializeRow(object sender, RowEventArgs
e)
{
// don't show the arrow for the last level
if (((ContainerGridRecord
)e.Row).Level < 3)
((
ContainerGridRecord)e.Row).IsEmptyParent = true
;
}
private void
BindGrid()
{
DataSet ds = new DataSet
();
ds.Tables.Add(
"Categories"
);
ds.Tables[
"Categories"].Columns.Add("CategoryID"
);
ds.Tables[
"Categories"].Columns.Add("CategoryName"
);
ds.Tables[
"Categories"].Rows.Add("1", "A"
);
ds.Tables[
"Categories"].Rows.Add("2", "B"
);
ds.Tables[
"Categories"].Rows.Add("3", "C"
);
List<Category> list = new List<Category
>();
foreach (DataRow dr in
ds.Tables[0].Rows)
{
list.Add(
new Category { CategoryName = dr.ItemArray[1].ToString(), CategoryID = Int32
.Parse(dr.ItemArray[0].ToString()) });
}
whdg1.DataSource = list;
}
private void BindSecondLevel(Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs
e)
{
// Get the data key
int key = (int
)e.Row.DataKey[0];
DataSet ds = new DataSet
();
ds.Tables.Add(
"Products"
);
ds.Tables[
"Products"].Columns.Add("ProductID"
);
ds.Tables[
"Products"].Columns.Add("ProductName"
);
ds.Tables[
"Products"].Rows.Add("1", "PA"
);
ds.Tables[
"Products"].Rows.Add("2", "PB"
);
ds.Tables[
"Products"].Rows.Add("3", "PC"
);
// Create Container Grid
ContainerGrid childGrid = new ContainerGrid
();
e.Row.RowIslands.Add(childGrid);
// Bind Grid
childGrid.DataKeyFields =
"ProductID"
;
childGrid.Level = 1;
childGrid.DataSource = ds.Tables[
"Products"
];
childGrid.DataBind();
}
private void BindThirdLevel(Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs
e)
{
// Get the data key
int key = (int
)e.Row.DataKey[0];
DataSet ds = new DataSet
();
ds.Tables.Add(
"OrderDetails"
);
ds.Tables[
"OrderDetails"].Columns.Add("OrderID"
);
ds.Tables[
"OrderDetails"].Columns.Add("Quantity"
);
ds.Tables[
"OrderDetails"].Rows.Add("1", "10"
);
ds.Tables[
"OrderDetails"].Rows.Add("2", "20"
);
ds.Tables[
"OrderDetails"].Rows.Add("3", "30"
);
// Create Container Grid
ContainerGrid childGrid = new ContainerGrid
();
e.Row.RowIslands.Add(childGrid);
childGrid.
// Bind Grid
childGrid.DataKeyFields =
"OrderID"
;
childGrid.Level = 2;
childGrid.DataSource = ds.Tables[
"OrderDetails"
];
childGrid.DataBind();
}
public void whdg1_RowIslandsPopulating(object sender, ContainerRowCancelEventArgs
e)
{
//Cancel the default automatic load on demand operation
e.Cancel =
true
;
switch
(e.Row.Level)
{
case
0:
BindSecondLevel(e);
break
;
case
1:
BindThirdLevel(e);
break
;
}
}
protected void Page_Load(object sender, EventArgs
e)
{
BindGrid();
}
}
public
class
Category
{
public int CategoryID { get; set
; }
public string CategoryName { get; set
; }
aspx
<
form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<ig:WebHierarchicalDataGrid DataKeyFields="CategoryID" ID="whdg1" runat="server" Height="350px"
Width="100%" oninitializerow="whdg1_InitializeRow" AutoGenerateBands="false" InitialExpandDepth="0" InitialDataBindDepth="0"
onprerender="whdg1_PreRender"
onrowislandspopulating="whdg1_RowIslandsPopulating">
</ig:WebHierarchicalDataGrid>
</div>
</form>
I am getting following error on expanding the 2nd level grid
—————————
Message from webpage
—————————
[NullReferenceException]: Object reference not set to an instance of an object.
at Infragistics.Web.UI.GridControls.ContainerGrid.RaisePostDataChangedEvent()
at System.Web.UI.Page.RaiseChangedEvents()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
[HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown.
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.customwebhierarchicalgrid_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\a052194a\ed07ab01\App_Web_c4nk_s-e.0.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
—————————
OK
—————————
-
-
0
-
0
Hi Lyuba,
How do I enable the initial expand depth when the AutoGenerateBands and AutoGenerateColumns are both false? I need to display 2 levels of hierarchical data expanded. It is working when the bands are not defined.
I tried setting InitialDataBindDepth, InitialExpandDepth and MaxDataBindDepth both in design and run-time, but no luck.
WebHierarchicalDataGrid1.InitialDataBindDepth = 1; //2
WebHierarchicalDataGrid1.InitialExpandDepth = 1; //2
WebHierarchicalDataGrid1.MaxDataBindDepth = 2; //2I would appreciate your kind help!
Thanks
-
0Hi Ram,I suppose you are trying to set this properties for a regular webhierarchicaldatagrid(not one with manual load on demand)? It should make no difference about this properties when you have autogeneratebands and autogeneratecolumns set to false. Can you give me the markup of your grid to take a look?LyubaDeveloper Support EngineerInfragistics
-
0
Hi Lyuba,
Here is the markup for the WebHierarchichalDataGrid –
<ig:WebHierarchicalDataGrid ID="ProjectWebHierarchicalDataGrid" runat="server" Height="350px" Width="100%" DataMember="ProductFamily" DataKeyFields="PRODUCT_FAMILY_ID" AutoGenerateBands="false" AutoGenerateColumns="false" InitialDataBindDepth="1" InitialExpandDepth="1">
<Columns>
<ig:BoundDataField DataFieldName="PRODUCT_FAMILY_DESCRIPTION" Key="PRODUCT_FAMILY_DESCRIPTION" Header-Text="Product Family" />
</Columns>
<Bands>
<ig:Band DataMember="Project" DataKeyFields="PROJECT_ID" AutoGenerateColumns="false">
<Columns>
<ig:BoundDataField DataFieldName="ARCHITECTURE_YEAR" Key="ARCHITECTURE_YEAR" Header-Text="Year" />
<ig:BoundDataField DataFieldName="PROJECT_NAME" Key="PROJECT_NAME" Header-Text="Project Name" />
<ig:BoundDataField DataFieldName="PROJECT_STATUS_DESCRIPTION" Key="PROJECT_STATUS_DESCRIPTION" Header-Text="Status" />
</Columns>
<Behaviors>
<ig:Sorting />
</Behaviors>
</ig:Band>
</Bands>
<Behaviors>
<ig:Sorting />
</Behaviors>
</ig:WebHierarchicalDataGrid>
I created a dataset with 2 data tables and the data tables are related with the PRODUCT_FAMILY_ID column. I could see 2 rows in the parent table and 1 row each for the parent in the child table. The hierarchical grid does not expand the 2nd level. Whereas if I don't create the bands and columns and set the AutoGenerateBands and AutoGenerateColumns to true, it shows the 2nd level expanded. Please advise!
-
-
0
-
0
Lyuba,
Actually I found solution in current version:
-
0
yes, i have done parent level every postback rebind gird, but i have do child gird (ContainerGrid) level also????
Please find the below of my code(ASPX with CS Code).
ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="whdg_New.aspx.cs" Inherits="whdg_New" %>
<!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>WHDG Test Page</title>
<script type="text/javascript" language="javascript">
function IndexChanged() {
debugger;
var dropdownlist = document.getElementById("WebHierarchicalDataGrid1_ctl00_2_0_ctl00_DropDownList1");
var grid = $find("WebHierarchicalDataGrid1");
var gridView=grid.get_gridView();
var rows =null;
if(gridView !=null)
rows = gridView.get_rows();
if (rows !=null && rows.get_row != null && rows.get_row.length > 0)
{
var childGridView = rows.get_row(1).get_rowIslands()[0];
childGridView.get_behaviors().get_paging().get_pageIndex() + 1;
if(childGridView != null)
{
var newValue = dropdownlist.selectedIndex;
childGridView.get_behaviors().get_paging().set_pageIndex(newValue);
}
}
}
function PreviousPage() {
debugger;
var grid = $find("WebHierarchicalDataGrid1");
var dropdownlist = document.getElementById("WebHierarchicalDataGrid1_ctl00_2_0_ctl00_DropDownList1");
var gridView=grid.get_gridView();
var rows =null;
if(gridView !=null)
rows = gridView.get_rows();
if (rows !=null && rows.get_row != null && rows.get_row.length > 0)
{
var childGridView = rows.get_row(1).get_rowIslands()[0];
childGridView.get_behaviors().get_paging().get_pageIndex() + 1;
if(childGridView != null)
{
if( childGridView.get_behaviors().get_paging().get_pageIndex() > 0 ) {
childGridView.get_behaviors().get_paging().set_pageIndex(childGridView.get_behaviors().get_paging().get_pageIndex() – 1);
}
}
}
}
function NextPage() {
var grid = $find("WebHierarchicalDataGrid1");
debugger;
var dropdownlist = document.getElementById("WebHierarchicalDataGrid1_ctl00_2_0_ctl00_DropDownList1");
var gridView=grid.get_gridView();
var rows =null;
if(gridView !=null)
rows = gridView.get_rows();
if (rows !=null && rows.get_row != null && rows.get_row.length > 0)
{
var childGridView = rows.get_row(1).get_rowIslands()[0];
childGridView.get_behaviors().get_paging().get_pageIndex() + 1;
if(childGridView != null)
{
if(childGridView.get_behaviors().get_paging().get_pageIndex() < childGridView.get_behaviors().get_paging().get_pageCount() – 1) {
childGridView.get_behaviors().get_paging().set_pageIndex(childGridView.get_behaviors().get_paging().get_pageIndex() + 1);
}
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ig:WebScriptManager ID="WebScriptManager1" runat="server" AsyncPostBackTimeout="100000" >
</ig:WebScriptManager>
<br />
<br />
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server"
AutoGenerateColumns="False" AutoGenerateBands="False" DataKeyFields="Pre_Main_ID"
InitialDataBindDepth="0"
Height="627px"
Width="90%"
OnRowIslandsPopulating="WebHierarchicalDataGrid1_RowIslandsPopulating"
OnInitializeRow="WebHierarchicalDataGrid1_InitializeRow" >
<ExpandCollapseAnimation SlideOpenDuration="300"
SlideCloseDuration="300" />
<AjaxIndicator Enabled="True" BlockArea="Control" BlockCssClass="ig_AjaxIndicatorBlock" />
<Columns>
<ig:BoundDataField DataFieldName="Pre_Main_ID" Hidden="True" Key="Pre_Main_ID">
<Header Text="Pre_Main_ID" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Month" Key="Month">
<Header Text="Month" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="CompletedHouseCalls" Key="CompletedHouseCalls">
<Header Text="Completed House Calls" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Reviewed" Key="Reviewed">
<Header Text="Reviewed" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Reviewed_Pre" Key="Reviewed_Pre">
<Header Text="Reviewed%" />
</ig:BoundDataField>
<ig:TemplateDataField Key="GenerateInvoice">
<ItemTemplate>
<asp:Button Text="Generate Invoice" runat="server" />
</ItemTemplate>
</ig:TemplateDataField>
</Columns>
<Bands>
<ig:Band AutoGenerateColumns="False" DataKeyFields="NP_Main_ID" >
<Columns>
<ig:BoundDataField DataFieldName="NP_Main_ID" Hidden="True" Key="NP_Main_ID">
<Header Text="NP_Main_ID" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Pre_Main_Ref" Hidden="True" Key="Pre_Main_Ref">
<Header Text="Pre_Main_Ref" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="NP_Name" Key="NP_Name">
<Header Text="NP" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Completed_Number" Key="Completed_Number">
<Header Text="Completed" />
</ig:BoundDataField>
<ig:TemplateDataField Key="Reviewed">
<ItemTemplate>
<!–<asp:HyperLink ID="hprlink" runat="server" Font-Bold="true" ForeColor="blue"><%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "Reviewed") %></asp:HyperLink> –>
<asp:Label ID="Label1" runat="server"><%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "Reviewed") %></asp:Label>
</ItemTemplate>
<Header Text="Reviewed" />
</ig:TemplateDataField>
</Columns>
<Bands>
<ig:Band AutoGenerateColumns="False" DataKeyFields="Member_ID" >
<Columns>
<ig:BoundDataField DataFieldName="Member_ID" Hidden="True" Key="Member_ID">
<Header Text="Member_ID" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="NP_Main_Ref" Hidden="True" Key="NP_Main_Ref">
<Header Text="NP_Main_Ref" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="MemberName" Key="MemberName">
<Header Text="MemberName" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="AssessmentDate" Key="AssessmentDate">
<Header Text="AssessmentDate" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="County" Key="County">
<Header Text="County" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="ReviewStatus" Key="ReviewStatus">
<Header Text="Reviewed" />
</ig:BoundDataField>
<ig:TemplateDataField Key="IsReview">
<ItemTemplate>
<asp:HyperLink ID="hprlink" runat="server" NavigateUrl="#"
Font-Bold="true" ForeColor="blue"><%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "IsReview")%>
</asp:HyperLink>
</ItemTemplate>
</ig:TemplateDataField>
</Columns>
</ig:Band>
</Bands>
</ig:Band>
</Bands>
</ig:WebHierarchicalDataGrid>
</div>
</form>
</body>
</html>
Code Behind
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Infragistics.Web.UI.GridControls;
using Infragistics.Web.UI.DataSourceControls;
public partial class whdg_New : System.Web.UI.Page
{
ContainerGrid childGrid = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
else
{
this.WebHierarchicalDataGrid1.DataSource = Cache["PRECEPTORS_MAIN"];
}
}
protected void WebHierarchicalDataGrid1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
{
string key = string.Empty;
key = e.Row.DataKey[0].ToString();
if ((((ContainerGridRecord)e.Row)).Level == 0)
{
DataRow[] drSelectedRow = ((DataSet)Cache["PRECEPTORS_MAIN"]).Tables[1].Select(" [Pre_Main_Ref] = " + key.ToString());
if (drSelectedRow != null && drSelectedRow.Length > 0)
{
((ContainerGridRecord)e.Row).IsEmptyParent = true;
}
}
if ((((ContainerGridRecord)e.Row)).Level == 1)
{
DataRow[] drSelectedRow = ((DataSet)Cache["NP_MAIN"]).Tables[1].Select(" [NP_Main_ref] = " + key.ToString());
if (drSelectedRow != null && drSelectedRow.Length > 0)
{
((ContainerGridRecord)e.Row).IsEmptyParent = true;
}
}
}
protected void WebHierarchicalDataGrid1_RowIslandsPopulating(object sender, Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs e)
{
//Cancel the default automatic load on demand operation
e.Cancel = true;
switch (e.Row.Level)
{
case 0:
if (e.Row.RowIslands.Count == 0)
{
BindSecondLevel(e);
}
break;
case 1:
if (e.Row.RowIslands.Count == 0)
{
BindThirdLevel(e);
}
break;
}
}
private void BindGrid()
{
SqlParameter[] spParameters = new SqlParameter[3];
SqlParameter sqlpar = null;
sqlpar = new SqlParameter("@Pre_Main_Ref","");
spParameters[0] = sqlpar;
sqlpar = new SqlParameter("@NP_Main_Ref", "");
spParameters[1] = sqlpar;
sqlpar = new SqlParameter("@mode", "0");
spParameters[2] = sqlpar;
DataSet ds = new DataSet("PRECEPTORS_MAIN");
DBConnection.retrieveEHouseCallDetails("Select_Main_SP", ref ds, System.Data.CommandType.StoredProcedure, spParameters);
ds.Tables[0].TableName = "PRECEPTORS_MAIN";
ds.Tables[1].TableName = "NPS_MAIN_IDs";
Cache["PRECEPTORS_MAIN"] = ds;
WebHierarchicalDataGrid1.DataSource = ds;
}
private void BindSecondLevel(Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs e)
{
// Create Container Grid
childGrid = new ContainerGrid();
// Get the data key
string Key = e.Row.DataKey[0].ToString();
SqlParameter[] spParameters = new SqlParameter[3];
SqlParameter sqlpar = null;
sqlpar = new SqlParameter("@Pre_Main_Ref", Key);
spParameters[0] = sqlpar;
sqlpar = new SqlParameter("@NP_Main_Ref", null);
spParameters[1] = sqlpar;
sqlpar = new SqlParameter("@mode", "1");
spParameters[2] = sqlpar;
DataSet dsChild = new DataSet("NPS_MAIN");
DBConnection.retrieveEHouseCallDetails("Select_Main_SP", ref dsChild, System.Data.CommandType.StoredProcedure, spParameters);
dsChild.Tables[0].TableName = "NPS_MAIN";
dsChild.Tables[1].TableName = "MEMBERS_MAIN";
Cache["NP_MAIN"] = dsChild;
if (dsChild != null && dsChild.Tables[0].Rows.Count > 0)
{
// Bind Grid
e.Row.RowIslands.Add(childGrid);
childGrid.Level = 1;
childGrid.DataSource = dsChild;
childGrid.Band = (Band)WebHierarchicalDataGrid1.Bands[0];
childGrid.Behaviors.CreateBehavior<Paging>();
childGrid.Behaviors.Paging.Enabled = true;
childGrid.Behaviors.Paging.PageIndex = 0;
childGrid.Behaviors.Paging.PageSize = 2;
//childGrid.Behaviors.Paging.PagerTemplate = new CustomPagerTemplate();
childGrid.PageIndexChanged += new PageIndexChangedHandler(childGrid_PageIndexChanged);
}
}
void childGrid_PageIndexChanged(object sender, PagingEventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
}
private void BindThirdLevel(Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs e)
{
// Create Container Grid
childGrid = new ContainerGrid();
// Get the data key
string Key = e.Row.DataKey[0].ToString();
SqlParameter[] spParameters = new SqlParameter[3];
SqlParameter sqlpar = null;
sqlpar = new SqlParameter("@Pre_Main_Ref", null);
spParameters[0] = sqlpar;
sqlpar = new SqlParameter("@NP_Main_Ref", Key);
spParameters[1] = sqlpar;
sqlpar = new SqlParameter("@mode", "2");
spParameters[2] = sqlpar;
DataSet dsChild = new DataSet();
DBConnection.retrieveEHouseCallDetails("Select_Main_SP", ref dsChild, System.Data.CommandType.StoredProcedure, spParameters);
dsChild.Tables[0].TableName = "MEMBERS_MAIN";
if (dsChild != null && dsChild.Tables[0].Rows.Count > 0)
{
e.Row.RowIslands.Add(childGrid);
// Bind Grid
childGrid.Level = 2;
childGrid.DataSource = dsChild;
childGrid.Band = (Band)WebHierarchicalDataGrid1.Bands[0].Bands[0];
}
}
}
Please help me urgent!!!!!
Warm & Best Regards,
Raja S -
0
I am using three level Hierarchical binding So how i need rebind each of every level page load dataSet. now i am using below the Page_Load code even i am getting issues.
So Do you have any idea about this each level dataSet rebind
My Page Load Code below:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
else
{
if (Cache["PRECEPTORS_MAIN"] != null)
{
this.WebHierarchicalDataGrid1.DataSource = Cache["PRECEPTORS_MAIN"];
}
foreach (ContainerGridRecord BandLevelFirstRow in WebHierarchicalDataGrid1.GridView.Rows)
{
if (BandLevelFirstRow.RowIslands.Count > 0)
{
if (((ContainerGrid)BandLevelFirstRow.RowIslands[0]).Key == "NPS_MAIN")
{
if (Cache["NP_MAIN"] != null)
((ContainerGrid)BandLevelFirstRow.RowIslands[0]).DataSource = Cache["NP_MAIN"];
foreach (ContainerGridRecord BandLevelSecondRow in ((ContainerGrid)BandLevelFirstRow.RowIslands[0]).Rows)
{
if (BandLevelSecondRow.RowIslands.Count > 0)
{
if (((ContainerGrid)BandLevelSecondRow.RowIslands[0]).Key == "MEMBERS_MAIN")
{
if (Cache["MEMBERS_MAIN"] != null)
((ContainerGrid)BandLevelSecondRow.RowIslands[0]).DataSource = Cache["MEMBERS_MAIN"];
}
}
}
}
}
}
}
}
Please help me urgent !!!!!!!. becuase we have 10000 records for second level and third level binding, So we need implement custom paging sever event.
Is this WHDG really useful for Hierarchical Data binding three level and paging?
Warm & Best Regards,
Raja S
-
0
Hi Lyuba,
May I please let me know which is the latest service release it will work???
Urgent !!!!
Warm & Best Regards,
Raja S-
0
Rajalingam,
Sorry I got sidetracked and only now returning to this task. Have you figured out paging on the child level when child bands a bound to the datasets as well?
If not – can someone from Infragistics help?
I will continue my own research and will post any results I find.
-
0
Hello ygalanter,
There is no feature in WHDG for Parent & Child level custom paging based on query selection(dataSet).
I have request to new feature release as :
"In the grid show paging by a specified record count and page size. Upon loading the paging numbers will show initially. Once the page number is clicked then a query can be executed to return by the specified page. This would allow the database to only query what records will show on the grid by a page selected. (Include Parent & Child grid also…)".
Let's us wait for a new feature release.
Warm & Best Regards,
Raja S.
-
-
- You must be logged in to reply to this topic.
Suggested Discussions
Adding bands and colums to WebHierarchicalDataGrid with behind code
Hello How to add bands and colums to WebHierarchicalDataGrid from DataSet using C#. I have to…Call UserControl in code behind c#
There is a UserControl named as “UcGridMastersUI.ascx” in my WebApplication, below is t…Add button inside webdatagrid columns from code behind
Hi , how can i add a button inside webdatagrid column from code behind ?Changing the Column Width from code behind
Hi, I have a requirement where I need to set the width of a column to "Auto". I am able t…Created by
Created on
May 3, 2019 12:51 PM
Last activity on
May 3, 2019 12:51 PM