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


相关推荐

  • 电容是根据什么分类_电容的分类与识别图片

    电容是根据什么分类_电容的分类与识别图片一、瓷介电容器(CC)1.结构用陶瓷材料作介质,在陶瓷表面涂覆一层金属(银)薄膜,再经高温烧结后作为电极而成。瓷介电容器又分1类电介质(NPO、CCG));2类电介质(X7R、2X1)和3类电介质(Y5V、2F4)瓷介电容器。2.特点1类瓷介电容器具有温度系数小、稳定性高、损耗低、耐压高等优点。最大容量不超过1000pF,常用的有CC1、CC2、CC18A、CC11、CCG等系…

    2022年8月22日
    6
  • hashmap线程不安全问题_java多线程编程面试题

    hashmap线程不安全问题_java多线程编程面试题https://blog.csdn.net/swl1993831/article/details/91896811

    2022年10月11日
    2
  • R语言作图——density plot(密度图)

    R语言作图——density plot(密度图)原创黄小仙上次分享了小提琴曲线(violinplot)的作图方法,今天小仙同学给大家介绍一下如何用R画出漂亮的密度图(densityplot)。Step1.绘图数据的准备首先还是要把你想要绘图的数据调整成R语言可以识别的格式excel中保存成csv格式。数据的格式如下图:一列表示一种变量,第一行是列名Step2.绘图数据的读取data<-read.csv(“your…

    2022年10月16日
    3
  • EasyUI 时间格式化「建议收藏」

    EasyUI 时间格式化「建议收藏」方法1:formatter:function(value,row,index){                           var unixTimestamp = new Date(value);                           return unixTimestamp.toLocaleString();                           }方法2…

    2022年5月12日
    36
  • Linux下 解决Tomcat8不自动解压war包[通俗易懂]

    Linux下 解决Tomcat8不自动解压war包[通俗易懂]之前买了阿里云服务器后配置好了jdk,Tomcat,mysql等。然后就想当然的将项目打成war包,直接拖到Tomcat的webapps下,但无论怎么重启项目就是不自动解压,后来查了各方面资料,删除这个文件那个文件的,差点把Tomcat搞崩溃了也没找到原因,最后看到讲一个将Tomcat里面配置文件的文章我才发现原来是tomcat/conf下server.xml里面的这行配置搞的鬼。其中:…

    2022年10月4日
    3
  • ubuntu分区方案图解_win7分区最大多少G

    ubuntu分区方案图解_win7分区最大多少G新手参考/boot200M/30G/home66G/swap4G

    2025年6月17日
    2

发表回复

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

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