RadControls for ASP.NET Ajax 笔记(1)

RadControls for ASP.NET Ajax 笔记(1)(1)遍历Grid中的所有Item(一行),一次仅展开一行【Singleexpandinhierarchicalgrid】privatevoidRadGrid1_ItemCommand(objectsource,Telerik.Web.UI.GridCommandEventArgse){if(e.CommandName==RadGrid.ExpandCo…

大家好,又见面了,我是你们的朋友全栈君。

(1)遍历Grid中的所有Item(一行),一次仅展开一行【Single expand in hierarchical grid】

private void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
if(e.CommandName == RadGrid.ExpandCollapseCommandName)
  {
foreach(GridItem item in e.Item.OwnerTableView.Items)
   {
if(item.Expanded && item != e.Item)
    {
     item.Expanded = false;
    }
   }
  }
}

http://www.telerik.com/help/aspnet-ajax/grdsingleexpandinhierarchicalgrid.html

(2)展开或者折叠所有行

protected void RadGrid1_ItemCommand(object source, Telerik.WebControls.GridCommandEventArgs e) 

    { 

if (e.CommandName == RadGrid.ExpandCollapseCommandName) 

        { 

            (e.Item.FindControl(“btnExpand”) as ImageButton).Visible = !(e.Item.FindControl(“btnExpand”) as ImageButton).Visible; 

            (e.Item.FindControl(“btnCollapse”) as ImageButton).Visible = !(e.Item.FindControl(“btnCollapse”) as ImageButton).Visible; 

        } 

if (e.CommandName == “ExpandAll”) 

        { 

//Looping through each DataItem and making the “btnExpand” image button in the item visibility  to false and  “btnCollapse” visibility to true 

foreach (GridDataItem GridDataItem in RadGrid1.MasterTableView.GetItems(new GridItemType[] { GridItemType.Item, GridItemType.AlternatingItem })) 

            { 

                ImageButton btnExpand = (ImageButton)GridDataItem.FindControl(“btnExpand”); 

                btnExpand.Visible = false; 

                ImageButton btnCollapse = (ImageButton)GridDataItem.FindControl(“btnCollapse”); 

                btnCollapse.Visible = true; 

            } 

//Exapanding the DataItem

foreach (GridDataItem item in RadGrid1.Items) 

            { 

                item.Expanded = true; 

            } 

//Hiding the CollapseAll image in the header to true and ExpandAll image in the header to false

            GridHeaderItem GridHeaderItem = e.Item as GridHeaderItem; 

            ImageButton imgCollapseAll = (ImageButton)GridHeaderItem.FindControl(“CollapseAll”); 

            imgCollapseAll.Visible = true; 

            ImageButton imgExpandAll = (ImageButton)GridHeaderItem.FindControl(“ExpandAll”); 

            imgExpandAll.Visible = false; 

        } 

if (e.CommandName == “CollapseAll”) 

        { 

//Looping through each DataItem and making the “btnExpand” image button in the item visibility  to true and  “btnCollapse” visibility to false 

foreach (GridDataItem GridDataItem in RadGrid1.MasterTableView.GetItems(new GridItemType[] { GridItemType.Item, GridItemType.AlternatingItem })) 

            { 

                ImageButton btnExpand = (ImageButton)GridDataItem.FindControl(“btnExpand”); 

                btnExpand.Visible = true; 

                ImageButton btnCollapse = (ImageButton)GridDataItem.FindControl(“btnCollapse”); 

                btnCollapse.Visible = false; 

            } 

//Collapsing the DataItem

foreach (GridDataItem item in RadGrid1.Items) 

            { 

                item.Expanded = false; 

            } 

//Hiding the CollapseAll image in the header to false and ExpandAll image in the header to true

            GridHeaderItem GridHeaderItem = e.Item as GridHeaderItem; 

            ImageButton imgCollapseAll = (ImageButton)GridHeaderItem.FindControl(“CollapseAll”); 

            imgCollapseAll.Visible = false; 

            ImageButton imgExpandAll = (ImageButton)GridHeaderItem.FindControl(“ExpandAll”); 

            imgExpandAll.Visible = true; 

        } 

    } 

http://www.telerik.com/community/code-library/aspnet-ajax/grid/custom-expand-collapse-column-with-expandall-collapseall-image-button-in-the-header.aspx

(3)导致Grid重新绑定数据【Commands that invoke Rebind() implicitly】

Here is the complete list of commands that trigger Rebind():

Command Name

Field

ExpandCollapse
RadGrid.ExpandCollapseCommandName

Update
RadGrid.UpdateCommandName

Cancel
RadGrid.CancelCommandName

Delete
RadGrid.DeleteCommandName

Edit
RadGrid.EditCommandName

InitInsert
RadGrid.InitInsertCommandName

PerformInsert
RadGrid.PerformInsertCommandName

RebindGrid
RadGrid.RebindGridCommandName

Page
RadGrid.PageCommandName

Sort
RadGrid.SortCommandName

Filter
RadGrid.FilterCommandName

Note that the following commands do not perform internal rebind:

Select
RadGrid.SelectCommandName

Deselect
RadGrid.DeselectCommandName

http://www.telerik.com/help/aspnet-ajax/grdcommandsthatinvokerebindimplicitly.html

转载于:https://www.cnblogs.com/emanlee/archive/2009/05/30/1492554.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/162001.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 伯努利分布、二项式分布与多项式分布简介「建议收藏」

    伯努利分布、二项式分布与多项式分布简介「建议收藏」一,伯努利分布(bernoulidistribution)又叫做0-1分布,指一次随机试验,结果只有两种。也就是一个随机变量的取值只有0和1。记为:0-1分布或B(1,p),其中p表示一次伯努利实验中结果为正或为1的概率。 概率计算:P(X=0)=p0P(X=1)=p1期望计算:E(X)=0∗p0+1∗p1=p最简单的例子就是,抛一次硬币,预测…

    2022年10月11日
  • 最新Spring整合MyBatis详解教程

    最新Spring整合MyBatis详解教程目录1.导入相关jar包1.junit2.mybatis3.mysql4.spring相关5.aop织入6.mybatis-spring7.lombok(选用)2.回顾:建立一个Mybatis程序1.IDEA连接数据库2.编写MyBatis核心配置文件3.创建数据库表对应实体类4.编写Mapper接口5.编写Mapper.xml配置文件6.编写测试类7.给Mapper.xml添加注册8.测试运行3.spring整合方式一:1.引入spring配置文件2.使用Sprin

    2022年4月28日
  • 2D动画编辑器–FSprite Designer

    2D动画编辑器–FSprite Designer

    2021年8月23日
  • 平台开发文档_快速开发平台

    平台开发文档_快速开发平台转自【作者:手机即信息博客:http://canco.javaeye.com】   手机可分为智能手机开发和featherphone手机。开发平台可分为开放式平台和封闭式平台,开放式平台包括symbian、windowsmobile、linux、iPhone、Android、BlackBerry、j2me、brew等,支持手机应用程序通过OTA下载和安装;封闭式平台包括MTK、展讯、

    2022年8月12日
  • 手机游戏开发现状分析[通俗易懂]

    手机游戏开发现状分析[通俗易懂]随着近年来手机的日渐普及,手机游戏已经成为整个游戏领域发展速度最快的部分。根据英国某媒体研究公布的统计数据,今年的手机游戏市场的产值已经达到5.87亿美元,比去年年翻了一番。该公司预计到今后几年里这一市场的产值将达到目前的6倍,增至38亿美元。 我国的手机游戏在最近一年,也有了长足的发展。但是就其规模而言,还远远没有达到国外的水平。这其中原因很多,但有一点是可以肯定的,我国的手机游戏前景是光明

    2022年4月30日
  • cmd 里面运行git提示“不是内部或外部命令,也不是可运行的程序”的解决办法…

    cmd 里面运行git提示“不是内部或外部命令,也不是可运行的程序”的解决办法…

    2021年10月20日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号