I can't find a solution to hierarchical grid, could some please post sample code on how I can make it work.
I have 2 bands in the aspx page, with my colums in the first band. I am binding the grid to a datatable, this works I see the data. But I dont see or know how to show the plus or expand column, which when expanded will show or expand an area where I want to display a FormView.
Thanks
Here's how I populated a four-level hierarchical grid from four SqlDataReaders:
In the designer, I defined all my bands and columns, and turned AutoGenerateColumns off.
In my Page_Load:
Me.TenantListUltraWebGrid.DataSource = GetIpmRehabTenantDataset(Me.ProjectId, Me.IncludeFormerTenants)Me.TenantListUltraWebGrid.DataBind()
Which uses this function:
Dim lResult As New DataSet("TenantDataset")
Dim lTenantFamilyTable As New DataTable("Families") lResult.Tables.Add(lTenantFamilyTable) lResult.Tables("Families").Load(GetIpmRehabFamiliesByPropertyId(ProjectId, vIncludeFormerTenants)) lResult.Relations.Add(lResult.Tables("Units").Columns("UNIT_ID"), _ lResult.Tables("Families").Columns("UNIT_ID"))
Dim lIncomeSourceTable As New DataTable("IncomeSources") lResult.Tables.Add(lIncomeSourceTable) lResult.Tables("IncomeSources").Load(GetIpmRehabIncomeSourcesByPropertyId(ProjectId, vIncludeFormerTenants)) lResult.Relations.Add(lResult.Tables("FamilyMembers").Columns("FAMILY_MEMBER_ID"), _ lResult.Tables("IncomeSources").Columns("FAMILY_MEMBER_ID"))
End Function
The four "GetIpmRehab..." functions each return a SqlDataReader containing all the records related to any of the members of the top-level (lUnitTable) table.
In looking deeper, this example will not work for my. The data in my child table requires 2 parameters that come from the parent row.
I tried all sorts of trick, but no luck.
I tried binding the child row like so:protected void UltraWebGrid1_InitializeRow(object sender, EventArgs e) { UltraGridBand ugb = new UltraGridBand(); UltraGridColumn ugc = new UltraGridColumn("Child_Id", "", ColumnType.Custom, null); ugc.Width = new Unit("400 px"); ugb.Columns.Add(ugc); UltraWebGrid1.Bands.Add(ugb);
This made it possible for the Expand plus sign to show but the child row disappears after 2 seconds.
I deally I would like to display data in a FormView in the child row rather than in grid format.
Any help will be appreciated.
Darrell,
Thanks for clarifying the bands issue, I still havent grasped the bands properly.
I have been working with the example you provided, thanks. But, my problem is that two of the fields in the Parent Grid are needed for the child. So, the DataSet binding as in the example will not work. One of the fields in the parent is a table name for join in the stored procedure. I will probably need to bind the child grid on the databing on the row of the parent. How can this be done with UltraWebGrid? I have it running with a regular GridView right now.
<igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" Browser="Xml" DataKeyField="Request_Id, Request_Type" OnExpandRow="UltraWebGrid1_RowExpand" OnInitializeRow="UltraWebGrid1_InitializeRow" OnItemCommand="UltraWebGrid1_ItemCommand"><DisplayLayout AutoGenerateColumns="false" StationaryMargins="Header" ColWidthDefault="100px"SelectTypeRowDefault="Extended" RowHeightDefault="23px" AllowSortingDefault="Yes"HeaderClickActionDefault="SortSingle" AllowColSizingDefault="Free" RowSelectorsDefault="No"CellClickActionDefault="RowSelect" SelectTypeColDefault="Single" AllowUpdateDefault="Yes"GridLinesDefault="Horizontal" ViewType="Hierarchical">
I don't think you can do what you want to do. If I understand you, each record in band 0 has a different table from which it needs to draw records for a sub-band. This is pretty straight-forward in a GridView, because each parent record can have an independent sub-GridView that is only related to that particular parent. In an WebGrid, bands are related globally. So if you can't put all your data into a parent-child dataset, I don't think you're going to pull it off in a WebGrid.
Then again, perhaps someone cleverer than I can suggest...
Ed,
Thanks for your response.
I agree that in a GridView this can be done fairly easily but I suspect that it can be done with the UltraWebGrid as well if we could wire into the events of the UWG.
I would assume if I could tie into the row created event of the UWG and create a FormView, load it with data in code and bind it to the child of the Row. The problem here I am having is how to tie it into the child of the Row, do I do a band?
I hope someone who has done this with UWG can respond.
Thanks for reading.
I highly doubt you are going to be able to switch the child grid to a different control, in fact, I would say you aren't going to be able to do it. The WebGrid just doesn't support what you are trying to do (placing a FormView as the child band display object).
Hi Darrell,
I use a WHDG in my application. I am using a WHDS to bind the data. I don't want all the columns fetched in views to be displayed as some of them are used for my reference. I couldn't customize the columns AutoGenreated by the the WHDG. Is there a a way to do this?
As an alternative, I used the RowIslandsPopulating methode to bind a ContainerGrid as the child grid. And I managed to show only the necessary columns. But the problem with this is I am not able to edit the data in cells. Is it possible to make ContainerGrid editable?