We currently use the UltraWebGrid from way back in the day and I thought it would be a good idea to start developing our new solutions in the latest version of the controls that Infragistics offers, but I'm having some trouble getting the binding & subsequent data display working on the WHDG control the way I want it to.
For demo purposes let's just say that I have a single dataset with two tables that contain two columns each. Table 1 contains the fields WeekNumber and StartOfWeek while Table 2 contains WeekNumber and WeekDate. I've added a data relation between the two tables to the dataset that joins on the WeekNumber fields.
If I drop a WHDG control onto my web form and set the DataKeyFields = WeekNumber and the InitialDataBindDepth to -1 and leave the autogeneratebands/columns = true then the data loads fine and I'm able to expand the header rows and view the child records.
My problem is that I don't want to auto generate the bands or columns as I need to be able to hide certain columns and also turn on editing for certain columns on both the parent & child rows.
Since this works when I use the autogenerate methods I must be missing, or simply don't understand, something obvious when I am setting up the Root and Child bands thru the WHDG smart tag. Does anyone have any examples showing a solution like this, or is there some bit of documentation that I completely missed?
Thanks for any help.
This is what the code behind looks like
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load'Create the generic data Dim ds1 As New DataSet Dim dt1 As New DataTable Dim dt2 As New DataTable
dt1.Columns.Add("WeekNumber") dt1.Columns.Add("StartOfWeek") dt2.Columns.Add("WeekNumber") dt2.Columns.Add("WeekDate")
Dim a, b As Integer For a = 0 To 2 Dim dt1NewRow As DataRow = dt1.NewRow dt1NewRow("WeekNumber") = a dt1NewRow("StartofWeek") = DateAdd(DateInterval.Day, a + 7, Today.Date) dt1.Rows.Add(dt1NewRow) For b = 0 To 4 Dim dt2NewRow As DataRow = dt2.NewRow dt2NewRow("WeekNumber") = a dt2NewRow("WeekDate") = DateAdd(DateInterval.Day, b, Today.Date) dt2.Rows.Add(dt2NewRow) Next Next
ds1.Tables.Add(dt1) ds1.Tables.Add(dt2)
Dim rel1 As New DataRelation("GoalHeaderToDailyActivity", ds1.Tables(0).Columns("WeekNumber"), ds1.Tables(1).Columns("WeekNumber")) ds1.Relations.Add(rel1)
'Bind the ds to the grid whdgTest.DataSource = ds1 whdgTest.DataBind()End Sub
This is the control html code: <ig:WebHierarchicalDataGrid ID="whdgTest" runat="server" DataKeyFields="WeekNumber" Height="350px" InitialDataBindDepth="-1" Width="400px"> </ig:WebHierarchicalDataGrid>
This html code has the bands called out, but it doesn't work this way, but it's the way I need it to work:<ig:WebHierarchicalDataGrid ID="whdgTest" runat="server" AutoGenerateBands="False" AutoGenerateColumns="False" DataKeyFields="WeekNumber" Height="350px" Key="Parent" Width="400px"> <Columns> <ig:BoundDataField DataFieldName="WeekNumber" Key="WeekNumber"> <Header Text="Week #" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="StartOfWeek" Key="StartOfWeek"> <Header Text="Start Date" /> </ig:BoundDataField> </Columns> <Bands> <ig:Band DataKeyFields="WeekNumber" Key="Child"> <Columns> <ig:BoundDataField DataFieldName="WeekDate" Key="WeekDate"> <Header Text="Day of Week" /> </ig:BoundDataField> </Columns> <Behaviors> <ig:EditingCore> <Behaviors> <ig:CellEditing> <ColumnSettings> <ig:EditingColumnSetting ColumnKey="WeekDate" /> </ColumnSettings> <EditModeActions MouseClick="Single" /> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors> </ig:Band> </Bands> <Behaviors> <ig:Activation> </ig:Activation> <ig:EditingCore> <Behaviors> <ig:CellEditing> <ColumnSettings> <ig:EditingColumnSetting ColumnKey="WeekNumber" ReadOnly="True" /> </ColumnSettings> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors> </ig:WebHierarchicalDataGrid>
Anyone? This seems like basic functionality, I've dropped down to using the UltraWebGrid to get what I want done, but I'd rather being using the WHDG, especially since it looks so much nicer to the end user.
Thanks.
I'm a little confused by the way you're question is worded vs. the code you included. I usually use SQLDataSource and then add the WHDS and then the WHDG controls. (also a script manager). Then I set up the WHDS to do the linking and then when I set up the WHDG through the smart tag. I do not use the autogenerate but rather when in the "Edit Bands" section and have selected a specific Band to work on, I click on the "Columns" property (under Layout) to set which columns I want displayed and how I want them to be displayed and function. Similar to any other infragistics grid. What I can't help you with is how the smart tags work when you're creating the data components in the Page_Load but I would assume you can programically modify the columns displayed and their functionality by working with a columns property of the band.