zoukankan      html  css  js  c++  java
  • [转]Infragistics NetAdvantage UltraWebGrid使用技巧

    Infragistics系列控件是一套很好,很强大的控件,前些日子公司买的正版的asp.net版本的..好像800多美元一套...最新版本的7.3....感觉很好..现在自己做项目也用..却发现网上没有一套中文的教程,中文资料都很少..在这里就把自己的研究心得写下来...
    首先安装,一步一步装就可以了..完成之后,有几点说明的
    1.安装完之后开始-程序的菜单里有Create Visual Studio Toolbox Tab.要执行一下.在vs的工具箱里生成infragistics的标签..不然连控件都找不到哦...菜单里还有一个sample...能实现的效果大部分都在里面了...根据你自己的需求,可以在里面找....菜单里还有个document..里面有各个控件的'指南','例子'.还有api和客户端脚本api...
    2.安装程序会在C:/Inetpub/wwwroot/aspnet_client/infragistics下生成一个包含运行时资源文件夹(包括图片,css等文件)..所以这个文件夹比较重要(在你没有appstle的情况下)...后面会说
    3.然后在安装目录下有dll文件的打包.我这里是C:/Program Files/Infragistics/NetAdvantage for .NET 2007 Vol. 3 CLR 2.0/ASP.NET/Bin - Signed这个文件夹.网站发布时.要把这个rar文件解压到bin文件夹下.不然没有dll文件怎么执行啊..
    4.还附送了一个appstylelist的小软件,可以设置空间外观,有了这个就不用去学习,设置那些复杂的外观属性了.非常方便..而且用了这个,2里提到的那个文件夹几乎就没用了...
    5.在你第一次拖动一个控件到页面时..会在你得根目录下生成一个licenses.licx文件..不要删了哦..
    6.可以在虚拟主机下运行,看到网上有得文章说还要手动iis虚拟路径之类的..不需要..只要把相关文件(图片和dll)考到项目里的相关附录就可以了..
    前言部分就这么多了..之后会说说控件..每种控件的功能,用法,代码控制的方法..

    转于http://blog.csdn.net/jingshuaizh/archive/2008/07/22/2689440.aspx

    Infragistics ASP.NET控件用法总结
    一、UltraWebGrid的基本用法
    1、 如何手工增加列
    第一步:将ControlSetting->DisplayOut->AutoGenerate置为False:表示不让控件自动添加列;
    第二步:添加自己需要的列:BaseColumnName即你要梆定的字段名; Key:指定该列的别人,方便以后寻找该列的值; Header->Caption: 表头文字
    2、 冻结某列
            this.UltraWebGrid1.DisplayLayout.UseFixedHeaders = true;
            this.UltraWebGrid1.Bands[0].Columns.FromKey("Edit").Header.Fixed = true;
    3、 向表格中添加其它控件
    ControlSetting->Columns->选中你要操作的列->EditorControlID->选择你要梆定的控件名
    4、 表格中添加一列Button按钮
    ControlSettings->Columns->选中要修改为安按钮的行->Type->Button
    5、 合并单元格
    Control Settings->Columns->列名->Header->RowLayoutColumnInfo;
    SpanX:跨几列    OriginX:哪一列开始
    //增加一个带图片的表头
    foreach(Infragistics.WebUI.UltraWebGrid.UltraGridColumn c in e.Layout.Bands[0].Columns)
    {
        c.Header.RowLayoutColumnInfo.OriginY = 1;
    }
    // 添加一个大的表头
    Infragistics.WebUI.UltraWebGridColumnHeader ch = new Infragistics.WebUI.UltraWeb
    GridColumnHeader(true);
    ch.Caption = “大表头的名字”          
            ch.RowLayoutColumnInfo.OriginY = 0; //设置添加表头的Y轴位置
    ch.RowLayoutColumnInfo.SpanX = 3;   //设置要跨的列数
    ch.Image.Url ="./images/bankingbtn.gif"; //添加图片
    ch.Image.AlternateText = "Employee Name Grouping";
    e.Layout.Bands[0].HeaderLayout.Add(ch); //将上面的设置添加到该表中
    6、 添加一数字控件,并设置为可点击累加数字
    第一步:将控件WebNumericEdit->SpinButtons->Display设置为:OnRight
    第二步:将UltraWebGrid中要梆定该控件的那一列的Type设置为:Custom
    * 设置某列只读; Allupdate = no
    7、 隐藏表头顶端的那一行
    DisplayLayout->GroupByBox->Hidden = true
    8、 固定Header那一行
    this.UltraWebGrid1.DisplayLayout.StationaryMargins = Infragistics.WebUI.UltraWebGrid. StationaryMargins.Header;
          
    9、 指定列头中字体的显示位置
    Control Settings->Band[0]->HeaderStyle->HorizontalAlign = Center
          
           10、指定表格中字体的显示位置
    Control Settings->Band[0]->RowStyle->HorizontalAlign = Center   //全部
              Control Settings->Columns->列名->CellStyle->HorizontalAlign = Center //设订某一列
           11、整张表不允许编辑
                  Control Settings->Band[0]->AllUpdate = no
           12、选择一行
                  Control Settings->Band[0]->CellClickAction = RowSelect
           13、增加一行
                  UltraWebGrid.DisplayLayout.Row.Add();
           14、确认对话框事件
    指定客户端事件:UltraWebGrid1->DisplayLayout->ClientSizeEvents-> ClickCellButtonHandler:CellButtonClick
                  函数的定义:
        function CellButtonClick(gridName, cellId)
        {
               if (cellId.substring(cellId.lastIndexOf("_") + 1, cellId.lastIndexOf("_") + 3) == "8")
               {
                      return !confirm("确信要删除此行数据吗?");
               }
           }
    15、分页处理
           UltraWebGrid1->DisplayOut->Pager->AllowPaging=True,然后是PageSize等设置。
           Pattern设置:这个模板就是用来自定义显示效果的
           <table width=100%><tr> [page:1:首页] 第[currentpageindex]页 共[pagecount]页 [prev] [next]</td><td align=right> [default]<td></tr></table>
    二、WebCombo的基本用法
    1、 实现可输可选的下拉表格
    Editable->True
    2、 将下拉表格加载到UltraWebGrid中去
            UltraWebGrid1.Columns[1].Type = ColumnType.DropDownList;  
            UltraWebGrid1.Columns[1].ValueList.WebCombo = WebComboGood
     
     
     
    Infragistics NetAdvantage UltraWebGrid使用之一
     

    在一个UltraWebGrid的第一个column(Template Column)放了一個Checkbox ,检查整个UltraWebGrid中的勾取情況,然后执行相关的操作。

    foreach(datarow row in grid.rows)
    {
    checkbox c = (checkbox)row.columns[0].findcontrol("checkbox");
    if(c.checked)
    {
    //do shomething by row data
    }
    }

    //取得全部的TemplateColumn,她把第一个列(column)数据都放在一个列表中
    UltraWebGrid.TemplatedColumn tcol = (WebUI.UltraWebGrid.TemplatedColumn)UltraWebGrid1.Bands[0].Columns[0];
    //取得每一個column的Cell內容
    foreach (Infragistics.WebUI.UltraWebGrid.CellItem item in tcol.CellItems)
    {
    CheckBox chkIsHaveRight = (CheckBox)item.FindControl("chkIsSendEmail");
    if (chkIsHaveRight.Checked == true)
    {
    //通過訪問父對象取得其他資料
    //item->cell->row->cell[4]->內容;在這過程中cell是item的父對象,row是cell的父對象,再訪問row下面的每4個Cell,再取得該Cell的內容。
    string info = item.Cell.Row.Cells[4].Text;
    }
    }

    1. UltraWebGrid添加模板列:
          先选择UltraWebGrid --属性--columns--勾选Templated column 即可
          
           <igtbl:TemplatedColumn AllowResize="Free" BaseColumnName="BT" ChangeLinksColor="True"
                                HeaderText="标题" Key="BT" Type="HyperLink">
                                <CellTemplate>
                                    <asp:LinkButton ID="LinkButton1" CssClass="WordBreak" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"AQJYGXID") %>' Text='<%# DataBinder.Eval(Container.DataItem,"BT") %>' ToolTip='<%# DataBinder.Eval(Container.DataItem,"BT") %>' CommandName="showdetail" runat="server" Font-Underline="false"></asp:LinkButton>
                                </CellTemplate>
                                <Header Caption="标题">
                                    <RowLayoutColumnInfo OriginX="2" />
                                </Header>
                                <Footer>
                                    <RowLayoutColumnInfo OriginX="2" />
                                </Footer>
                            </igtbl:TemplatedColumn>


    2. UltraWebGrid日期列:
          设置日期列的 Format属性:yyyy-MM-dd(Date)
          DataType属性为System.DateTime


    3。取某行的某列(列名:BIDPRICE)的值:  
    UltraWebGrid1.Rows[i].Cells.FromKey("BIDPRICE").Value或者UltraWebGrid1.Rows[i].Cells[j].Value  
    取某列:UltraWebGrid1.Columns.FromKey("BIDPRICE").Value


    4。标题行居中显示:
          <HeaderStyleDefault BackColor="LightGray" BorderStyle="Solid" HorizontalAlign="Center">
                     </HeaderStyleDefault>
       
    对应项居中    <CellStyle HorizontalAlign="Center"></CellStyle>

    5.UltraWebGrid的固定列功能
        具体步骤:
            (1) 在UltraWebGrid下的DisplayLayout中把TableLayout属性设为:Fixed ; UseFixedHeaders设为:True //这是指定Grid允许固定列
    StationaryMargins="Header" //这使Header始终在最上面显示
    (2) 设定列固定: Header下面的Fixed设置为true。这样就可以实现ID固定了,但效果图中还有一个功能就是,点击后面的任何一个列后的“图钉”图标,就可以任意进行多列固定了。如下图为我点击了“ContactName”的效果:这种功能的实现,只要修改一个属性:FixedHeaderIndicatorDefault="Button"就可以了。

    6。UltraWebGrid 最下面线显示问题:
           选择UltraWebGrid点击》选择Bands And Columns的DefaultrowHeight设置高度 即可。


    7.   选择一行以后获得选定行指定列的值
    if (e.InnerCommandEventArgs.CommandName == "showdetail")
            {
                int id = Convert.ToInt32(e.InnerCommandEventArgs.CommandArgument);
               
                for (int i = 0; i < UltraWebGrid1.DisplayLayout.SelectedRows.Count; i++)
                {
                    if (UltraWebGrid1.DisplayLayout.SelectedRows[i].Cells[6].Text == "未审批")//选取一行以后获得选定行指定列的值
                   {
                        string url2 = "../zhishishenbaobiao/zssbview.aspx?id=" + id + " ";
                        Page.RegisterStartupScript("showinfo", "<script>window.open('" + url2 + "','未审批知识信息查看','width=850,height=600,toolbar=no,scrollbars=yes,status=yes,resizable=yes');</script>");

                    }
                    else
                    {
                        string url2 = "../zhishishenbaobiao/showview.aspx?id=" + id + " ";
                        Page.RegisterStartupScript("showinfo", "<script>window.open('" + url2 + "','已审批知识信息查看','width=850,height=600,toolbar=no,scrollbars=yes,status=yes,resizable=yes');</script>");

                    }
                }
               
            }

    7. UltraWebGrid 单击单元格选中行
            (1) 选择UltraWebGrid-displayout CellClickActionDefault=RowSelected
            (2)   选择UltraWebGrid-智能选择卡--Bands And Columns--Band[“”]--SelectRowStyle的BackColor属性
      

    8. 设置UltraWebGrid的第0列为模板列,加入CheckBox控件,判断其状态是否被选中,代码如下:    

           //可以写在任何地方,属于通用代码
    Infragistics.WebUI.UltraWebGrid.TemplatedColumn    tcol   =   (TemplatedColumn)UltraWebGrid1.Bands[0].Columns[0];//模板列
    foreach(CellItem    item   in    tcol.CellItems)
       {             
               System.Web.UI.WebControls.CheckBox    chkIsHaveRight   =    (System.Web.UI.WebControls.CheckBox)item.FindControl("chbShenhe");
              if(chkIsHaveRight.Checked == true)
               {
                      //进行相关的操作
                }
       }


    9.禁止操作列
    (1) 禁止操作一列数据
       Infragistics.WebUI.UltraWebGrid.TemplatedColumn tcol = (TemplatedColumn)UltraWebGrid1.Bands[0].Columns[9];//模板列
                        foreach (CellItem item in tcol.CellItems)
                        {
                            System.Web.UI.WebControls.ImageButton chkIsHaveRight = (System.Web.UI.WebControls.ImageButton)item.FindControl("ImageButton3");
                            chkIsHaveRight.Enabled = false;
                        }
    (2) 禁止操作某列中已审批列
    Infragistics.WebUI.UltraWebGrid.TemplatedColumn tcol = (TemplatedColumn)UltraWebGrid1.Bands[0].Columns[9];//模板列
         foreach (CellItem item in tcol.CellItems)
                            {
                                System.Web.UI.WebControls.ImageButton chkIsHaveRight = (System.Web.UI.WebControls.ImageButton)item.FindControl("ImageButton3");
                                if (item.Cell.Row.Cells[6].Text == "已审批")
                                {
                                    chkIsHaveRight.Enabled = false;//已审批按钮禁止选择
                                }
                                else
                                {
                                    chkIsHaveRight.Enabled = true;
                                }

                            }


    10. webgrid 的 RowChanged 事件没有相应

           解决:客户端代码中<LayoutSettings AllowAddNew="Yes" AllowDelete="Yes" AllowEdit="Yes" RowChangedAction="OnTheFlyPostback">

                  </LayoutSettings>
                   设置RowChangedAction="OnTheFlyPostback"


    11 .客户端事件在哪里添加

    解决:<LayoutSettings AllowAddNew="Yes" AllowDelete="Yes" AllowEdit="Yes" RowChangedAction="OnTheFlyPostback">

                                            <ClientSideEvents OnRowValidate="wgUserRole_OnRowValidate" />

                                            </LayoutSettings>

                  ClientSideEvents 中可以添加客户端事件


    12.WebGrid 的列内容唯一
              解决: 因为我们是通过 datatable 绑定的。。绑定前 DataColumn 设置列.Unique = true;

    13.隐藏一列

    解决:把改列的宽设置为 0px 或者 UltraWebGrid1.Columns[i].Hidden = true;

    14.WebGrid在IE6和IE7中拖动错位解决办法:
           修改aspx页面中的
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 4.0 Transitional//EN">.

    15.按WebGrid排序列

    protected void UltraWebGrid2_SortColumn(object sender, SortColumnEventArgs e)
        {
            string newSortDirection;
            string sqltemp = "";
            //正逆序切换
            if (oldSortDirection == "ASC")
                newSortDirection = "DESC";
            else
                newSortDirection = "ASC";
            oldSortDirection = newSortDirection;
            if (e.ColumnNo != 0)
            {
                if (sqlwhere != "")
                {
                    sqltemp +=" " + UltraWebGrid1.Columns[e.ColumnNo].Key + " " + newSortDirection;
                    moDataView.RowFilter = "1=1" + sqlwhere;//sqlwhere查询条件
                    moDataView.Sort = sqltemp;//按选择字段排序
                    if (moDataView.Count == 0)
                    {
                       UltraWebGrid1.DataSource = moDataView;
                        UltraWebGrid1.DataBind();
                    }
                    else
                    {
                        UltraWebGrid1.DataSource = moDataView;
                        UltraWebGrid1.DataBind();
                    }
                }
                else
                {
                    moDataView.RowFilter = "";
                    UltraWebGrid1.DataSource = moDataView;
                    UltraWebGrid1.DataBind();
                }
             }
        }

     
     
    Infragistics NetAdvantage 组件说明 WebGrid(二)
     

    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
    Infragistics NetAdvantage 组件说明 WebGrid(三)

    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中的列。

    Infragistics NetAdvantage 组件说明 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"

  • 相关阅读:
    视图中使用select a.* 更改了表a的结构 导致读取字段值时发生错位
    sql 压缩文件(rar或zip)
    单击触发jquery.autocomplete的两种方法
    CSS布局时容易出的小错误,导致浏览器不兼容或者各种不显示
    使用备份数据库.bal文件还原正在使用的数据库
    sql outer join
    利用GBK双字节编码突破PHP单引号转义限制进行SQL注入:set names gbk导致的sql注入
    对可操作对象的占用状态、锁定状态、解锁状态的一些方案
    回车转换成Tab
    DataGrid超级连接列
  • 原文地址:https://www.cnblogs.com/jackljf/p/3589162.html
Copyright © 2011-2022 走看看