zoukankan      html  css  js  c++  java
  • 关于Infragistics.WebUI.UltraWebGrid的使用

    nfragistics.WebUI.UltraWebGrid功能比较强大,尤其是客户端时间比较丰富,能实现较多的控制。下面就有关个别客户端事件稍微说明一下。

    在.cs代码中添加


    UltraWebGrid1.DisplayLayout.ClientSideEvents.CellClickHandler = "Template_CellClickHandler";
    UltraWebGrid1.DisplayLayout.ClientSideEvents.ColumnHeaderClickHandler = "Template_ColumnHeaderClickHandler";
    UltraWebGrid1.DisplayLayout.ClientSideEvents.AfterCellUpdateHandler = "Template_AfterCellUpdateHandler";
    UltraWebGrid1.DisplayLayout.ClientSideEvents.AfterRowActivateHandler = "Template_AfterRowActivateHandler";

    以上四个分别为:单元格单击事件,列头单击事件,单元格更新后事件,选择行事件。

    注意单元格单击事件需要在前面页面该控件的样式布局部分修改CellClickActionDefault="CellSelect",如果是

    行选择CellClickActionDefault="RowSelect"


    <DisplayLayout RowHeightDefault="24px" Version="4.00" BorderCollapseDefault="Separate" LoadOnDemand="Xml" TableLayout="Fixed" 
                     CellClickActionDefault="CellSelect" SelectTypeRowDefault="Single" RowSelectorsDefault="No" SelectTypeCellDefault="Extended">

    然后编写客户端事件


    //声明几个常用的全局变量
    var CurrentGrid=null;
    var CurrentRowIndex=-1;
    var CurrentColumnIndex=-1;
    var CurrentRow=null;
    var CurrentCell=null;

    //单元格单击
    function Template_CellClickHandler(gridName, cellId, button)
    {   
        if(button==2)
            return;
            
        CurrentGrid=igtbl_getGridById(UltraWebGrid1);
        CurrentCell=CurrentGrid.getActiveCell();
        CurrentColumnIndex=CurrentCell.Index;
        CurrentRow=CurrentCell.Row;
        CurrentRowIndex=CurrentRow.getIndex();

        //其他你要执行的js代码
    }

    //行单击事件 
    function Template_AfterRowActivateHandler(gridId,rowId)
    {
        CurrentRow=igtbl_getRowById(rowId);
        CurrentRowIndex=CurrentRow.getIndex();

        //其他你要执行的js代码
    }

    //表头单击事件(参数没写,自己找一下)
    function Template_ColumnHeaderClickHandler()
    {

    }

    //单元格更新后事件
    function Template_AfterCellUpdateHandler(gridName, cellId)
    {

    }

     其他一些常用操作

    function DeleteRow()
    {
        var row=igtbl_getActiveRow(UltraWebGrid1); 
        CurrentRow=row;
        //有时需要执行一些检查,满足一定条件后然后执行一个回调函数来删除,所以将当前行保存在全局变量中
        CurrentRow.deleteRow();
    }

    添加行:

    function InsertRow()
    {
        CurrentGrid=igtbl_getGridById(UltraWebGrid1);
        CurrentGrid.Rows.addNew();

        //得到刚添加的行,可以return(返回)刚添加的行,然后进行自动赋值等操作
        var row=igtbl_getRowById(CurrentGrid.Rows.getLastRowId());
        //得到当前行的下一行
        var row=CurrentRow.getNextRow();
    }

    根据Id得到某个行或单元格

    igtbl_getCellById(cellId);
    igtbl_getRowById(rowId);

    如果单元格是图片,可以这样赋值

    addCell.Element.innerHTML="<NOBR><IMG style=/"CURSOR: hand/" οnclick=InsertRow() src=/"../images/Default/add.bmp/"></NOBR>";

    如果是文本,应该

    row.getCell(columnIndex);
    cell.setValue();

    更多使用技巧完善中!

    转自 : https://blog.csdn.net/gangan1122/article/details/4013122

  • 相关阅读:
    Java中关于String类型的10个问题
    关于Linux中后台运行程序(&)退出时收不到SIGHUP信号的说明
    《Javascript DOM编程艺术》学习笔记 第8章 充实文档的内容
    《Javascript DOM编程艺术》学习笔记 第7章 动态创建标记
    《Javascript DOM编程艺术》学习笔记 第1-6章
    golang: 读取已关闭的缓冲型channel的表现
    关于《汇编语言(王爽)》程序6.3使用16个dw 0的问题
    关于寄存器的一些笔记
    img格式镜像转ISO格式
    深入理解计算机操作系统:第1章 计算机系统漫游(学习笔记)
  • 原文地址:https://www.cnblogs.com/ljx111/p/13357640.html
Copyright © 2011-2022 走看看