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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Google Chrome Frame 谷歌浏览器框架

    Google Chrome Frame 谷歌浏览器框架 一句话:GoogleChromeFrame让IE仅剩下皮囊。微软这回要哭了,Google最新发布的ChromeFrame可以将IE的Trident内核替换成WebKit,是IE一下子有了两内核(浏览器也双核了,厚厚~)。Google在帮助其竞争对手改善其产品,微软的IE开发团队是不是会很尴尬?在运行插件之后,用户的IE浏览器将获得Chrome的性能和功能,拥有更快的JS解析…

    2022年7月16日
    34
  • nginx负载均衡原理

    nginx负载均衡原理负载均衡在服务端开发中算是一个比较重要的特性。因为Nginx除了作为常规的Web服务器外,还会被大规模的用于反向代理前端,因为Nginx的异步框架可以处理很大的并发请求,把这些并发请求hold住之后就可以分发给后台服务端(backendservers,后面简称backend)来做复杂的计算、处理和响应,并且在业务量增加的时候可以方便地扩容后台服务器。负载均衡可以分为硬件负载均衡和软件负载均衡…

    2022年6月24日
    28
  • VBA宏编程_宏代码怎么用

    VBA宏编程_宏代码怎么用背景Office的编程语言较老,和现有高级语言相差较多,导致入门以及编写差异较大,编写和调试不方便,所以一直没考虑过使用VBA进行Office编程,但最近有个需求,是在无高级编程语言环境的内网主机上进行表格自动化处理,所以必须得用表格自带函数实现简单逻辑以及VBA实现复杂逻辑。…

    2022年5月3日
    47
  • 一张色环图教你搞定配色![通俗易懂]

    一张色环图教你搞定配色![通俗易懂]一张色环图教你搞定配色!不管是在平面设计或网页制作中,还是在平常生活中的衣服穿搭和室内装潢中,要想打造出非凡的视觉效果,合理的颜色搭配非常重要。下面介绍几种色彩搭配方案供您参考,让你轻易地一靶中的

    2022年8月5日
    6
  • extremeDB_shiro使用详解

    extremeDB_shiro使用详解1、准备工作:下载eXtremeDB安装包(http://www.leadingtek.com.cn/)然后将安装或解压至磁盘。此时可以看到其目录下有host、include、platform和target等目录。2、用你喜欢的文本编辑器构建一数据库结构,文本内容如下:(举例说明,保存文件名为test.mco)#defineint1    signed#definein

    2022年10月10日
    0
  • 浅谈路径规划算法_rrt路径规划算法

    浅谈路径规划算法_rrt路径规划算法原文地址:http://theory.stanford.edu/~amitp/GameProgramming/1导言1.1算法1.2Dijkstra算法与最佳优先搜索1.3A*算法2启发式算法2.1A*对启发式函数的使用2.2速度还是精确度?2.3衡量单位2.4精确的启发式函数2.4.1预计算的精确启发式函数2.4.2线性精

    2022年8月23日
    3

发表回复

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

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