See Also

UltraGridBand Members  | Infragistics.WebUI.UltraWebGrid Namespace

Language

Visual Basic

C#

Show All

See Also Languages Infragistics2.WebUI.UltraWebGrid.v7.2

UltraGridBand Class

Infragistics.WebUI.UltraWebGrid Namespace : UltraGridBand Class

The UltraGridBand object represents a single level of a hierarchical record set. The columns that make up a band are typically drawn from a single recordsource (table) in the data source.

For a list of all members of this type, see UltraGridBand members.

Object Model





























Syntax

[Visual Basic]
Public Class UltraGridBand    Inherits KeyedObjectBase    Implements ISupportRollback, IKeyedObjectIParticipateInAppStylingIXPathDataNavigable 
[C#]
public class UltraGridBand : KeyedObjectBase, ISupportRollback, IKeyedObjectIParticipateInAppStylingIXPathDataNavigable 

Remarks

The UltraGridBand object represents a set of related columns. These columns generally correspond to the fields in a recordset, but can also include computed columns added by the programmer. A band represents a grouping of all the data at a single level in a hierarchical recordset. In the case of flat data there is only 1 band, whereas a grid with hierarchical data will have multiple bands.

Although the Band object does not directly own any rows within the row hierarchy, it does control the appearance and behavior of those rows within its level of influence.

Example

This example creates the entire grid with the server-side API. All of the bands, columns, rows, and cells are created in code.

[Visual Basic] 

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If IsPostBack Then Exit Sub

        Dim DataSet As DataSet

        ' Get the data from the database via the middleware
        With New ReportSystem()
            DataSet = .GetYearlyExpenseReport
        End With

        ' Get a pointer to the first band
        Dim Band As Infragistics.WebUI.UltraWebGrid.UltraGridBand = UltraWebGrid1.Bands(0)
        ' Set the band key to Year
        Band.Key = "Year"

        ' Set the default Column Width and Row Height on the grid
        Band.DefaultColWidth = New Unit(50)
        Band.DefaultRowHeight = New Unit(20)

        ' Set the various style properties to class in our CSS file
        Band.HeaderStyle.CssClass = "HeaderClass"
        Band.FooterStyle.CssClass = "FooterClass"
        Band.RowAlternateStyle.CssClass = "AltRowClass"
        Band.SelectedRowStyle.CssClass = "SelCellClass"
        Band.RowStyle.CssClass = "ItemClass"

        ' Allow the bands to be expanded by the user
        Band.Expandable = Infragistics.WebUI.UltraWebGrid.Expandable.Yes

        ' Only show horizontal grid lines in our grid
        Band.GridLines = Infragistics.WebUI.UltraWebGrid.UltraGridLines.Horizontal

        ' Set the headers in the band to do a multi-column sort on click
        Band.HeaderClickAction = Infragistics.WebUI.UltraWebGrid.HeaderClickAction.SortMulti

        ' Do not show the row selectors on the end of the grid
        Band.RowSelectors = Infragistics.WebUI.UltraWebGrid.RowSelectors.No

        Dim Column As System.Data.DataColumn

        ' Loop the columns of the DataSet and build the columns of the grid
        For Each Column In DataSet.Tables("YearlyExpenses").Columns
            Dim ColumnName As String = Column.ColumnName

            ' Add the Column
            UltraWebGrid1.Bands.FromKey("Year").Columns.Add(ColumnName, ColumnName)
            ' and set it's size
            UltraWebGrid1.Bands.FromKey("Year").Columns.FromKey(ColumnName).Width = System.Web.UI.WebControls.Unit.Pixel(200)

            If ColumnName <> "Year" Then
                ' set it to right align
                UltraWebGrid1.Bands.FromKey("Year").Columns.FromKey(ColumnName).CellStyle.HorizontalAlign = HorizontalAlign.Right
            End If
        Next

        Dim DataRow As DataRow
        Dim Cell As Infragistics.WebUI.UltraWebGrid.UltraGridCell

        ' Loop each row to get the data to create the cells and rows
        For Each DataRow In DataSet.Tables("YearlyExpenses").Rows()
            ' Get a new row
            Dim GridRow As Infragistics.WebUI.UltraWebGrid.UltraGridRow = New Infragistics.WebUI.UltraWebGrid.UltraGridRow()

            ' Loop each column in the row to get the cell data
            For Each Column In DataRow.Table.Columns
                ' Create a new cell
                Cell = New Infragistics.WebUI.UltraWebGrid.UltraGridCell()
                ' If it is not the Year column format it as currency
                If Column.ColumnName <> "Year" Then
                    ' Put the DataSet column value into the Cell object
                    Cell.Value = System.String.Format("{0:C}", DataRow(Column.ColumnName))
                Else
                    ' Put the DataSet column value into the Cell object
                    Cell.Value = DataRow(Column.ColumnName).ToString
                End If
                ' Add the cell to the row
                GridRow.Cells.Add(Cell)
            Next

            ' Add the row to the Grid
            UltraWebGrid1.Rows.Add(GridRow)
        Next

        UltraWebGrid1.DisplayLayout.ViewType = Infragistics.WebUI.UltraWebGrid.ViewType.Hierarchical
        Band = New Infragistics.WebUI.UltraWebGrid.UltraGridBand()
        UltraWebGrid1.Bands.Add(band)

        ' Loop the columns of the DataSet and build the columns of the grid
        For Each Column In DataSet.Tables("YearlyExpenses1").Columns
            Dim ColumnName As String = Column.ColumnName

            ' Don't add year to the second band
            If ColumnName <> "Year" Then
                ' Add the Column
                Band.Columns.Add(ColumnName, ColumnName)
                ' and set it's size
                Band.Columns.FromKey(ColumnName).Width = System.Web.UI.WebControls.Unit.Pixel(200)

                If ColumnName <> "Region" Then
                    ' set it to right align
                    Band.Columns.FromKey(ColumnName).CellStyle.HorizontalAlign = HorizontalAlign.Right
                End If
            End If
        Next

        Dim row As Infragistics.WebUI.UltraWebGrid.UltraGridRow
        For Each row In UltraWebGrid1.Rows
            row.Rows.Band = Band
        Next

        ' Loop each row to get the data to create the cells and rows
        For Each DataRow In DataSet.Tables("YearlyExpenses1").Rows()
            ' Get a new row
            Dim GridRow As Infragistics.WebUI.UltraWebGrid.UltraGridRow = New Infragistics.WebUI.UltraWebGrid.UltraGridRow()

            ' Loop each column in the row to get the cell data
            For Each Column In DataRow.Table.Columns
                ' Don't do year again
                If Column.ColumnName <> "Year" Then
                    ' Create a new cell
                    Cell = New Infragistics.WebUI.UltraWebGrid.UltraGridCell()
                    ' If it is not the Region column format it as currency
                    If Column.ColumnName <> "Region" Then
                        ' Put the DataSet column value into the Cell object
                        Cell.Value = System.String.Format("{0:C}", DataRow(Column.ColumnName))
                    Else
                        ' Put the DataSet column value into the Cell object
                        Cell.Value = DataRow(Column.ColumnName).ToString
                    End If
                    ' Add the cell to the row
                    GridRow.Cells.Add(Cell)
                End If
            Next

            ' Add the row to the Grid
            UltraWebGrid1.Rows(CType(Right(DataRow("Year").ToString, 1), Int32) - 1).Rows.Add(GridRow)
        Next
    End Sub

See Also

UltraGridBand Members  | Infragistics.WebUI.UltraWebGrid Namespace

E-mail your feedback on this topic.

Opinion about our help? Take our survey.

Copyright © 1996-2007 Infragistics, Inc. All rights reserved.

Build Version: 7.2.20072.1063