• RadControls for ASP.NET Ajax 笔记(1)


    (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

  • 相关阅读:
    HuanGe'Linux Store上线了!
    4555
    google 代码
    曾经红透半边天的郭盛华,如今却拿着月薪5千的工资过生活,网友:到底经历了什么?
    揭秘:AI人工智能和摩尔定律的后指数时代
    黑客开始跨界攻击了,网络安全的未来在云端
    传奇人物郭盛华:汽车黑客,远远比我们想象中还要恐怖
    Facebook再现丑闻,约100位应用程序开发人员偷看用户数据
    郭盛华现身北京机场,颇有IT男的风范,网友:疑似被招安了
    郭盛华:中国网络的守护神,美俄黑客也要俯首称臣
  • 原文地址:https://www.cnblogs.com/emanlee/p/1492554.html
Copyright © 2020-2023  润新知