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


相关推荐

  • uva 11151 Longest Palindrome (最长公共子序列)[通俗易懂]

    uva 11151 Longest Palindrome (最长公共子序列)[通俗易懂]uva11151LongestPalindromeApalindromeisastringthatreadsthesamefromtheleftasitdoesfromtheright.Forexample,I,GAGandMADAMarepalindromes,butADAMisnot.Here,weconsideralso

    2022年7月11日
  • 【网络流24题】-题表

    【网络流24题】-题表最近都不知道自己在干什么==2016-11-0808:37:35转载于:https://www.cnblogs.com/Konjakmoyu/p/6041412.html

    2022年5月24日
  • 框架介绍

    MVC模式MVC模式介绍Django中的MVC模式分为三个部分此外,Django还有一个URL分发器。它的作用是将一个个URL的页面请求分别发给不同的Views处理,Views再调用相应的Mod

    2022年3月29日
  • dell服务器安装Ubuntu16.04桌面版(系统安装程序找不到磁盘,无法分区)「建议收藏」

    dell服务器安装Ubuntu16.04桌面版(系统安装程序找不到磁盘,无法分区)「建议收藏」前言前段时间笔者所在的公司服务器突然硬盘挂了,”剧情”需要,笔者担当起了运维的角色,自行在新到的硬盘安装系统,搭建服务器环境…p.s.笔者因为工作需要,在服务器上安装了Ubuntu16.04的桌面版。因为有时候确实很需要图形界面的Linux系统。2333本文仅供有系统安装的经验的同学参考…正文这里废话不多说,桌面版的Ubuntu(后面简称桌板)的和服务器版的Ubuntu(后面简称服版)对于普通电脑来说,安装方式都一样,那么对于服务器来说,桌版和服版来说,安装方式略有不同(这里后面会说到),但工具还

    2022年10月31日
  • 服务器系统监控工具,10款超实用的服务器监控工具和软件

    服务器系统监控工具,10款超实用的服务器监控工具和软件服务器监控软件和工具可以帮助我们从任何一个地方实时了解服务器的性能和功能。由于复杂的社交网络系统以及我们对于互联网的高度依赖,我们绝不允许那些宝贵的客户因自身系统停运而流失。选用实用的服务器工具和软件是一个明智的决定,能够同时为你带来短期效益和长期效益。下面是10款超实用的服务器监控工具和软件:1.SimpleServerMonitorSimpleServerMonitor是一款成本合理…

    2022年6月13日
  • 架构之业务架构[通俗易懂]

    架构之业务架构[通俗易懂]业务架构之产品经理的职责产品经理的职责用户的原始需求往往是零散和碎片化的,产品经理的职责就是:告诉用户,系统长什么样子;告诉开发,他要实现什么功能。产品经理定义了系统的外表。产品经理的职责:1、收集用户的原始需求,2、梳理成一个个业务流程,每个业务流程由多个业务步骤组成。一个业务步骤包含三部分的内容:输入、输出和业务功能。3、需求梳理好后,产品经理会把每个步骤具体化为页面原型。在原型中,会以直观的方式给出各个步骤的输入或输出,以及用户的操作过程,最后再把这些页面串起来,形成一个业

    2022年10月12日

发表回复

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

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