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


相关推荐

  • 在中国当程序员,35岁是分水岭?这些新路你知道吗?

    在中国当程序员,35岁是分水岭?这些新路你知道吗?程序员都应该看看

    2022年7月16日
    21
  • 乘法逆元一

    乘法逆元一乘法逆元一导入 分数取模考虑一个式子 x equiv dfrac 1 2 mod 7 即求一个数 x 它与 dfrac 1 2 模 7 的结果相同 称为 x 与 dfrac 1 2 对模 7 同余 分数取模不同于整数取模 但我们仍可以利用模运算的性质解决此题 模运算时两边同乘相同的数 两边仍然同余 所以将两边同乘

    2025年8月14日
    4
  • java开发简历项目经验_java工程师简历案例

    java开发简历项目经验_java工程师简历案例 最近我在帮朋友的公司招人,招人的第一步是要筛选简历,在这过程中,我发现虽然能收到很多简历,但实际能通过筛选能进入到技术面试流程的简历不多,估计10份里不会超过4份能通过筛选。  如果没法通过技术面试,那么候选人尚且能收集面试题,回家继续准备,毕竟他和面试官也交流过,也不算没收获,但对于这些没法通过筛选的简历,简历的主人往往是无从得知的(公司不会主动通知),所以他们依然会混混沌沌,可以预想,在…

    2022年9月23日
    5
  • 解决docker下载镜像速度过慢_docker image是什么

    解决docker下载镜像速度过慢_docker image是什么前言上一篇讲到pull镜像,但是pull镜像的时候下拉的速度实在感人,有什么解决办法吗?我们只需将docker镜像源修改为国内的将docker镜像源修改为国内的:在/etc/docker/d

    2022年7月29日
    16
  • MySQL修改数据表名

    MySQL修改数据表名修改数据表,包括:修改表名、修改字段名、修改字段的数据类型等。MySQL中,修改数据表的操作都是使用ALTERTABLE修改表名ALTERTABLE旧表名RENAME[TO]新表名;说明其中,TO是可选的,有没有都可以。首先,查看数据库中所有的表修改表名检查是否修改成功

    2022年5月31日
    83
  • Java开发已经烂大街,没前途了?假的

    Java开发已经烂大街,没前途了?假的经过了多年的发展,Java早已由一门单纯的计算机编程语言,演变为了一套强大的技术体系。在程序员中,Java开发工程师就占据20%的比例,不可否认,Java语言有着广泛的行业发展前景,它在行业中的影响力已是不可避免的。所以许多人想通过学习Java转行、找好工作,所以报班学习Java开发的人越来越多。很多人说Java开发已经烂大街了,现在学Java没前途。真的是这样的吗?现在学Java还有前途吗?本文,给大家详细解答一下。1、Java人才缺口大根据职友集数据显示,Java开发的全国招聘量123805条。从

    2022年7月8日
    255

发表回复

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

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