为Infragistics UltraWebGrid 行中的按钮添加操作确认提示

来源:互联网 发布:盼盼是什么交友软件 编辑:程序博客网 时间:2024/04/30 00:00

在项目的开发中应用了Infragistics.WebUI.UltraWebGrid这个控件,并把其中的两列设置为了“按钮”列,其中的一个按钮是实现页面跳转的功能,不需要提示,而另一列是实现对该行记录的删除功能,需要在删除前显示一个删除确认提示。经过推敲,找到解决的办法,具体做法如下:

一、在UltraWebGrid的属性中找到:DisplayLayout —> ClientSizeEvents —> ClickCellButtonHandler,点击此处,会出现“Add new handler...”提示,点击这个提示,在出现的对话框中为要添加的客户端事件命名(如:CellButtonClick),点击“OK”按钮。客户端脚本事件添加成功。

二、切换到UltraWebGrid所在页面的代码视图下,会看到自动添加的如下脚本:

<script id="Infragistics" type="text/javascript">
<!--
function  CellButtonClick(gridName, cellId){
    
//Add code to handle your event here.
    
}
// -->

在脚本方法中添加脚本:

<script id="Infragistics" type="text/javascript">
<!--
function   CellButtonClick(gridName, cellId){
    
//Add code to handle your event here.
                     
                     
//分析参数cellId的格式为:grid的ID+"rc_"+行索引+"_"+列索引  (如UltraWebGrid1rc_4_5)
                     //可以用以下方法获取按钮所在的列索引
    var colId = cellId.substring(cellId.indexOf('_')+1);
    colId 
= colId.substring(colId.indexOf('_')+1);
                     
                     
//根据索引的值,为相应列的按钮添加提示
    if(colId==6)
    
{
      
return(!confirm('你确定要删除该报表吗?'));
    }

}
// -->

经过如上步骤地处理,就可以为Infragistics UltraWebGrid 行中的按钮添加操作确认提示了。如还有其它方法,欢迎探讨。

原创粉丝点击