Infragistics NetAdvantage 组件说明 WebGrid

Rows对象介绍:

Band对象自己并不包含rows集合,rows集合只能被UlraWebGrid对象调用,这是因为rowsgrid的原始数据。换一种说法,rows插入到布局中。

Displayout,Bands,Columns只是显示、表现数据,但本身并不包含数据,是和数据分开的。所以,层次化是数据(rows)的固有特性,rows包含自己的row,每个row又可包含子rowsband的指向rows集合中合适的层次点。

Bands对象介绍:

Band对象的样式和行为作用于它所包含的所有的rows,另外,对于Columns对象,它说明描述每行中每个单元的数据的内容,band对象的属性可以覆盖原先DisplayLayout的缺省值。举例:grid AllowUpdatesFalse,但是对于band1)可以=True

Grid中至少包含一个band对象,并且这个bandband0)表示,这是顶层的band,它包含可以平面显示的gridrows数据。如果没有其他bandDisplayout中缺省值对于平面数据足够用了。如果利用多band显示分层数据,Displayout用于大多数band,对于个别的单独设置。

UltraWebGrid 服务器端对象树

开始于grid,grid-》bands-》band-》rows-》row-》cells-》cell

                                                   -》columns-》column


 

 

Grid

    Bands

      Band

        Rows          

          Row

            Cells

              Cell

        Columns

          Column

            ValueList

            ValidatorItemsCollection

    Columns

      Column

        ValueList

        ValidatorItemsCollection Object

    Rows

      Row

        Rows (Child Rows)

      Cells

        Cell

    Layout (DisplayLayout)

      Activation

      AddNewBox

      Bands

        Band

          Rows

            Row

      ClientSideEvents

      GroupByBox

      Pager

      Rows

        Row

          Rows (Child Rows)

      SelectedRows

        Row

      SelectedColumns

        Column

      SelectedCells

        Cell

 

 

 

UltraWebGrid 客户端对象树

Webgrid虽然是基于服务的控件,但是它也为客户端开发提供了强大的支持,Client Side Object Model是基于javascript对象模式的,它能许多功能而不需要往服务器回送。

Ø         Grid 对象:

通过var grid =igtbl_getGridById('UltraWebGrid1');获取,也可以直接引用oUltraWebGrid1

常用属性:

n         bands:得到属于这个gridbands数组

在客户端中没有bands集合对象,代替它的是利用gridbands属性来实现

var grid = igtbl_getGridById('UltraWebGrid1');

grid.bands[0].RowSizing = 2;

n         rows:返回所有gridband0)中所有rows

var grid = igtbl_getGridById('UltraWebGrid1');

grid.Rows.getRow(0).RowSizing = 2;

Ø         Band对象:

代表所有的与之层次对应的所有的rows

通过 var band = igtbl_getGridById('UltraWebGrid1').Bands[n];获取或var band = igtbl_getBandById('cellId');

常用属性:

n         Columns:得到一个Columns数组,原理类似于grid中的bands属性

var band = igtbl_getBandById('cellId');

band.columns[0].HeaderClickAction = 1;

Ø         Column对象

通过var col = igtbl_getGridById('UltraWebGrid1').Bands[n].Columns[m];获取或var col = igtbl_getColumnById('cellId');

常用方法:

n         SetHidden方法

setHidden(true):隐藏指定列

Ø         Cell对象

通过Row.getCell(n)获取

常用方法

n         SetValue

n         GetValue

n         GetPrevCell

n         getNextCell

Ø         Row对象

Row对象不是为grid中每行自动产生的,而是根据需要动态创建的

通过igtbl_getRowById(cellId)获取,或Rows.getRow(n)获取,或igtbl_getActiveRow(gridName)获取。

常用方法:

n         getCell(index)

返回当前行中指定的Cell对象,索引是从0开始的。

Ø         Rows集合对象

实际应用

数据源

Ø         Dataset

webgrid可以使用许多数据源,只要这些数据源实现IList, ITypedList or IBindingList 接口就可以应用。最强大之处可以包含多个相关的datatable,把这些datatable以分层grid的方式来表现。

UltraWebGrid1.DataSource = dataset

UltraWebGrid1.DataBind()

Ø         InitializeLayout事件中可以隐藏某列。

e.Layout.Bands(0).Columns.FromKey("Salary").Hidden = True

数据操作

Ø         显示一个值,存储另一个值

利用ValueList,dataValue,DisplayText

Dim valueList As Infragistics.WebUI.UltraWebGrid.ValueList

valueList = new Infragistics.WebUI.UltraWebGrid.ValueList()

valueList.ValueListItems.Add 1, "One"

valueList.ValueListItems.Add 2, "Two"

valueList.ValueListItems.Add 3, "Three"

valueList.DisplayStyle = Infragistics.WebUI.UltraWebGrid.ValueListDisplayStyle.DisplayText

UltraWebGrid1.DisplayLayout.Bands(0).Columns.FromKey("Notes").Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList

UltraWebGrid1.DisplayLayout.CellClickActionDefault = Infragistics.WebUI.UltraWebGrid.CellClickAction.Edit

 

 

UltraWebGrid1.DisplayLayout.Bands(0).Columns.FromKey("Notes").ValueList =  valueList

另外一种方式

UltraWebGrid1.Columns(0).Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList

Dim PlantList As ValueList = UltraWebGrid1.Columns(0).ValueList

PlantList.DataSource = db.getAllPlantInfo.Tables(0).DefaultView

PlantList.ValueMember = "plantnum"

PlantList.DisplayMember = "plantname"  必须和查询出的字段大小写一致

PlantList.DataBind()

UltraWebGrid1.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes

UltraWebGrid1.DisplayLayout.CellClickActionDefault = CellClickAction.Edit

关于表格原有数据键值或编号绑定问题

利用Cell.Title解决这个问题

Dim ds1 As DataSet

            ds1 = db.getAllPlantInfo

            UltraWebGrid1.Columns(0).Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList

            Dim PlantList As ValueList = UltraWebGrid1.Columns(0).ValueList

            PlantList.DataSource = ds1.Tables(0).DefaultView

            PlantList.ValueMember = "plantnum"

            PlantList.DisplayMember = "plantname"

            PlantList.DataBind()

            UltraWebGrid1.Columns(1).Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList

            Dim PlantList2 As ValueList = UltraWebGrid1.Columns(1).ValueList

            PlantList2.DataSource = ds1.Tables(0).DefaultView

            PlantList2.ValueMember = "plantnum"

            PlantList2.DisplayMember = "plantname"

            PlantList2.DataBind()

            UltraWebGrid1.DisplayLayout.AddNewBox.Prompt = "增加->"

            UltraWebGrid1.Bands(0).AddButtonCaption = "出让方"

            Dim ds As DataSet

            ds = db.getFdqjy

            UltraWebGrid1.DataSource = ds.Tables(0).DefaultView

       

            UltraWebGrid1.Columns(0).AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes

            UltraWebGrid1.Columns(1).AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes

            UltraWebGrid1.Columns(2).AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes

            UltraWebGrid1.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes

            UltraWebGrid1.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes

            UltraWebGrid1.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes

            UltraWebGrid1.DisplayLayout.CellClickActionDefault = CellClickAction.RowSelect

            UltraWebGrid1.DataBind()

            Dim en As UltraGridRowsEnumerator

            en = UltraWebGrid1.Bands(0).GetRowsEnumerator()

            Dim row As UltraGridRow

            While en.MoveNext() <> Nothing

                row = en.Current

                row.Cells(0).Title = ds.Tables(0).Rows(row.Index).Item(0)

                row.Cells(1).Title = ds.Tables(0).Rows(row.Index).Item(2)

            End While

说明:原希望通过cell.text cell.value解决,但是通过查询资料和试验,发现text作为value的辅助,他们的是重叠的,其中一个设置会覆盖另一个。Title则可以插入到celltag

Ø         用户接口:选择、激活、编辑

rowcell可以作为激活的对象,并且如果cell为激活则包含cellrow自动成为激活

Active不同于选择,多行可以选择,但在某一时刻只能有1 row 1 Cell可以是激活的。

Ø         去掉滚动条

Me.UltraWebGrid1.Width=Unit.Percentage(100)

Me.UltraWebGrid1.Height=Unit.Percentage(100)

Me.UltraWebGrid1.DisplayLayout.FrameStyle.CustomRules = "table-layout:auto"

Ø         行的选择和激活行

当指向一个行时,这个行就会编程active row,成为active row由以下几个因素决定,

1  当行中的某个cell进入编辑模式,行就自动成为激活;

2  选择行,多选时,最头一个行作为active row

3  通过代码UltraWebGrid1.DisplayLayout.ActiveRow = UltraWebGrid1.Rows(0)

可以调整active row的外观

UltraWebGrid1.DisplayLayout.ActiveRow.Style.BackColor = Color.Red

UltraWebGrid1.DisplayLayout.ActiveRow.Style.Border = Color.Blud

Ø         改变激活行

Dim objRow As Infragistics.WebUI.UltraWebGrid.UltraGridRow

objRow = Me.UltraWebGrid1.Rows(5)

Me.UltraWebGrid1.ActiveRow = objRow

Ø         Cell选择和激活

成为active cell的条件与行类似。

UltraWebGrid1.DisplayLayout.ActiveCell = UltraWebGrid1.Rows(0).Cells(0)

可以调整active cell的外观

UltraWebGrid1.DisplayLayout.ActiveCell.Style.BackColor = Color.Red

Ø         click Cell时进入编辑模式

Me.UltraWebGrid1.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes

Me.UltraWebGrid1.DisplayLayout.CellClickActionDefault = CellClickAction.Edit

Ø         cell中内嵌编辑控件

1  把编辑控件(日期选择控件)加入到页面中,把编辑控件的边设成None

2  加入webgriddisplayout.AllwoUpdateDefaultTrue

3  利用webgrid列属性向导关联编辑控件和webgrid中的列。

 

样式和格式

UltraWebGrid加载许多不同的样式对象,每个样式对象有自己的属性,

一些Style有相对应的default属性(对象?)比如:HeaderStyleDefaultRowStyleDefaultRowAlternateStyleDefault

常用属性:

Backcolor,BackGroundImage,BorderColor,BorderStyle,BorderWidth,Cursor,Font,ForeColor,Height,Width,Margin,Padding,HorizongtalAlign,VerticalAlgin,warp,

Ø         创建和应用样式

Dim style as GridItemStyle

style = new GridItemStyle()

style.BackColor = System.Drawing.Color.Red

style.ForeColor = System.Drawing.Color.White

style.BorderStyle = BorderStyle.Groove

style.BorderWidth = New Unit("3px")

style.BackgroundImage = "images/landscape.jpg"

style.Font.Bold = true

UltraWebGrid1.DisplayLayout.AddNewBox.Style = style

也可以直接设置

UltraWebGrid1.DisplayLayout.RowSelectorStyleDefault.BackColor = System.Drawing.Color.Red

设置表头样式

UltraWebGrid1.DisplayLayout.HeaderStyleDefault.CssClass = "TD_Header"

隐藏Row Select

Me.UltraWebGrid1.DisplayLayout.RowSelectorsDefault = Infragistics.WebUI.UltraWebGrid.RowSelectors.No

隐藏cell超出部分,用省略号表示

UltraWebGrid1.DisplayLayout.RowStyleDefault.Wrap = False

UltraWebGrid1.DisplayLayout.RowStyleDefault.TextOverflow = Infragistics.WebUI.UltraWebGrid.TextOverflow.Ellipsis

固定表头

UltraWebGrid1.DisplayLayout.StationaryMargins = Infragistics.WebUI.UltraWebGrid.StationaryMargins.HeaderAndFooter

根据Cell不同值显示不同样式

放置在UltraGridInitializeRow事件中

If e.Row.Cells.FromKey("Subject").Value = "Test" Then

e.Row.Cells.FromKey("Subject").Style.BackColor = System.Drawing.Color.Red

End If

固定某一列

UltraWebGrid1.DisplayLayout.UseFixedHeaders = True

UltraWebGrid1.DisplayLayout.FixedHeaderIndicatorDefault = FixedHeaderIndicator.Button

AddNewBox设置

UltraWebGrid1.DisplayLayout.AddNewBox.ButtonStyle.CssClass设置button的样式

UltraWebGrid1.DisplayLayout.AddNewBox.ButtonStyle.Cursor设置光标落在上面显示的样式

更新数据库

批量更新数据库,需要页面上有提交按钮

1  设置webgrid Update

2  设置default cell clickedit模式

3  增加guid隐藏列,实现可以新增多行

4  增加以下代码到InitializeLayout事件中

e.Layout.Bands(0).DataKeyField = "CustomerID"

e.Layout.AllowAddNewDefault = Infragistics.WebUI.UltraWebGrid.AllowAddNew.Yes

e.Layout.AllowDeleteDefault = Infragistics.WebUI.UltraWebGrid.AllowDelete.Yes

e.Layout.AllowUpdateDefault= Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes

e.Layout.AddNewBox.Hidden = False

e.Layout.CellClickActionDefault =Infragistics.WebUI.UltraWebGrid.CellClickAction.Edit

With e.Layout.Bands(0)

    .Columns.Add("GUID")

    .Columns.FromKey("GUID").Hidden = True

End With

1  增加一个集合收集增加的row

Dim c_colNewCustomerDataRows As New Collection()

2  编写LoadUpdatableDataSet公共方法供UpdateCellBatch, DeleteRowBatch, and AddRowBatch调用

Private Sub LoadUpdatableDataSet()

     If DataSet11.Customers.Rows.Count <= 0 Then

          OleDbDataAdapter1.Fill(DataSet11)

        Dim colGUID As New DataColumn("GUID", GetType(String))

        DataSet11.Customers.Columns.Add(colGUID)

End If

End Sub

3  UpdateCellBatch事件

Dim drCustomers As DataRow

LoadUpdatableDataSet()

' test to see if this cell goes into a new row

If e.Cell.Row.DataChanged = Infragistics.WebUI.UltraWebGrid.DataChanged.Added Then

    ' look in the collection for the new row

    drCustomers = CType(c_colNewCustomerDataRows.Item(

    e.Cell.Row.Cells.FromKey("GUID").Value.ToString), DataRow)

Else

    ' try to find row containing the changed cell

    Try

        drCustomers = DataSet11.Customers.FindByCustomerID( _

        e.Cell.Row.DataKey.ToString)

    Catch ex As Exception

        DisplayMessages("Original record not found for updating, key= " _

        & e.Cell.Row.DataKey.ToString)

    End Try

End If

' attempt to update the cell value

Try

    drCustomers(e.Cell.Column.Key) = e.Cell.Value

Catch ex As Exception

    DisplayMessages(ex.Message.ToString _

    , e.Cell.Column.Key, e.Data.ToString)

End Try

说明:webgrid更新引用dataset的更新方法,对dataset过于依赖,不灵活。关于更新可以利用原来河北地电系统中的方式。

ValueList的用法

DisplayMember

返回或设置表中的字段,而这个字段是提供给valueList的作为项用的

项值是用valueMember属性

DisplayMember联合ValueMember,提供一种方法存储一个值到数据源而显示另外一个值。换句话说,就是用户可以预置一些状态,比如,选择New York NY会存入到数据源中,在这个例子中New York作为DisplayMember属性,NY作为ValueMember属性。

分层数据显示

Ø         <DisplayLayout RowHeightDefault="20px" Version="4.00" BorderCollapseDefault="Separate" AutoGenerateColumns="False"  ViewType="Hierarchical" Name="UltraWebGrid1">

Ø         建立band

<igtbl:UltraGridBand BaseTableName="Plant">

       <Columns>

              <igtbl:UltraGridColumn HeaderText="plantnum" IsBound="True" Width="150px" BaseColumnName="plantnum" FooterText="">

                     <Header Caption="电厂编号"></Header>

              </igtbl:UltraGridColumn>

              <igtbl:UltraGridColumn HeaderText="plantname" IsBound="True" Width="150px" BaseColumnName="plantname" FooterText="">                                                       <Header Caption="电厂名称"></Header>

              </igtbl:UltraGridColumn>

              </Columns>

              </igtbl:UltraGridBand>                                      

              <igtbl:UltraGridBand BaseTableName="Unit">

              <Columns>

              <igtbl:UltraGridColumn HeaderText="unitnum" IsBound="True" Width="150px" BaseColumnName="unitnum" FooterText="">

                            <Header Caption="计量点编号">  </Header>

              </igtbl:UltraGridColumn>

              <igtbl:UltraGridColumn HeaderText="unitname" IsBound="True" Width="150px" BaseColumnName="unitname" FooterText="">

                            <Header Caption="计量点名称">  </Header>

              </igtbl:UltraGridColumn>                                                       

              </Columns>

              </igtbl:UltraGridBand>

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Infragistics NetAdvantage 2012是一款功能强大的软件集合,用于开发人员创建高质量的用户界面和数据可视化应用程序。它提供了丰富的工具和控件,帮助开发人员快速构建功能丰富、现代化的应用程序。 NetAdvantage 2012包括了多个精心设计的控件,如数据网格、图表、日历、工具栏等,它们可以轻松地集成到各种应用程序中。这些控件具有灵活的配置选项和丰富的样式,开发人员可以根据自己的需求进行自定义。此外,NetAdvantage 2012还提供了丰富的主题,使用户界面看起来更加专业和精美。 使用NetAdvantage 2012,开发人员可以快速创建直观、易于使用的应用程序。它提供了丰富的数据绑定功能,可以轻松地将控件与数据库或其他数据源进行绑定。开发人员还可以通过使用.Net框架的优势,轻松地处理和管理数据,从而提高应用程序的性能和可靠性。 此外,NetAdvantage 2012还提供了强大的图表功能,可以帮助开发人员将数据可视化并进行分析。图表控件支持多种图表类型,如柱状图、折线图、饼图等,开发人员可以根据需要选择合适的图表类型展示数据。图表控件还支持动画和交互功能,使用户能够更直观地理解和操作数据。 总而言之,Infragistics NetAdvantage 2012是一款功能强大的开发工具,提供了丰富的控件和功能,帮助开发人员快速构建现代化、高质量的用户界面和数据可视化应用程序。无论是企业应用程序还是个人项目,NetAdvantage 2012都可以为开发人员带来许多便利和高效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值