展开 RadGrid 层次结构中的所有项目

发布于 2024-08-12 04:09:36 字数 1527 浏览 2 评论 0原文

我正在使用具有层次结构的 RadGrid (2009 Q2)。客户端 api 有没有办法扩展所有行,反之亦然?

谢谢!

更新: 我根据下面迪克·兰帕德建议的 api 文档编写了一个 javascript 函数,用于展开/折叠具有三个级别的 radgrid 中的所有行。它会展开第一个 mastertableview 行的两个子级别中的所有 mastertableview 行和所有嵌套的detailtableview 行,但当它转到第二个 mastertableview 行的detailtableview 行时,它会中断(哇!)。我收到的错误是“_350 未定义”。这来自 Telerik.Web.UI.WebResource 文件。

function ExpandCollapseAll(expand) {
    var grid = $find("<%= rgHistory.ClientID %>");

    master = grid.get_masterTableView();
    var masterRowCount = master.get_dataItems().length;

    for (masterIndex = 0; masterIndex < masterRowCount; masterIndex++) {
        if (expand) {
            master.expandItem(masterIndex);
        }
        else {
            master.collapseItem(masterIndex);
        }
    } 

    var detailTables = grid.get_detailTables();
    var detailTableCount = detailTables.length;

    for (detailTableIndex = 0; detailTableIndex < detailTableCount; detailTableIndex++) {
        var detailTable = detailTables[detailTableIndex];
        var rowCount = detailTable.get_dataItems().length;
        for (rowIndex = 0; rowIndex < rowCount; rowIndex++) {
            if (expand) {
                //expandItem is failing!  detailTableIndex and rowIndex are correct
                detailTables[detailTableIndex].expandItem(rowIndex);
            }
            else {
                detailTables[detailTableIndex].collapseItem(rowIndex);
            }
        }
    }            
}

有什么想法吗?!?!

I am using a RadGrid (2009 Q2) with a hierarchy. Is there a way in the client api to expand all rows and vice-versa?

thanks!

Update:
I have written a javascript function based off the api documentation suggested by Dick Lampard below to expand/collapse all rows in a radgrid with three levels. It expands all the mastertableview rows and all the nested detailtableview rows in both sub levels of the first mastertableview row, but it breaks when it goes the to detailtableview rows for the second mastertableview row (whew!). The error I am getting is "_350 is undefined". This is coming from a Telerik.Web.UI.WebResource file.

function ExpandCollapseAll(expand) {
    var grid = $find("<%= rgHistory.ClientID %>");

    master = grid.get_masterTableView();
    var masterRowCount = master.get_dataItems().length;

    for (masterIndex = 0; masterIndex < masterRowCount; masterIndex++) {
        if (expand) {
            master.expandItem(masterIndex);
        }
        else {
            master.collapseItem(masterIndex);
        }
    } 

    var detailTables = grid.get_detailTables();
    var detailTableCount = detailTables.length;

    for (detailTableIndex = 0; detailTableIndex < detailTableCount; detailTableIndex++) {
        var detailTable = detailTables[detailTableIndex];
        var rowCount = detailTable.get_dataItems().length;
        for (rowIndex = 0; rowIndex < rowCount; rowIndex++) {
            if (expand) {
                //expandItem is failing!  detailTableIndex and rowIndex are correct
                detailTables[detailTableIndex].expandItem(rowIndex);
            }
            else {
                detailTables[detailTableIndex].collapseItem(rowIndex);
            }
        }
    }            
}

ANY IDEAS?!?!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

莫相离 2024-08-19 04:09:36

有用于层次结构扩展的客户端 API 以及 ExpandHierarchyToTop() 服务器方法。查看此演示

迪克

There is client API for hierarchy expansion as well as ExpandHierarchyToTop() server method. Check out this demo.

Dick

歌枕肩 2024-08-19 04:09:36

如果您想查看所有层次结构级别,请将 HierarchyDefaultExpanded 设置为 MasterTableView 和所有 GridTableView。请参阅此链接 了解更多详情。

If you would like to see all the hierarchy levels, Set HierarchyDefaultExpanded to the MasterTableView and all the GridTableViews. See this link for more details.

篱下浅笙歌 2024-08-19 04:09:36

试试这个

protected void Page_PreRenderComplete() {   
 if (!Page.IsPostBack) {    
   foreach (GridItem item in MyGrid.MasterTableView.Controls[0].Controls) {      
      if (item is GridGroupHeaderItem)
        if (item.GroupIndex.ToString() != "0")
          item.Expanded = !item.Expanded;
    } 
  } 
}      

Try This

protected void Page_PreRenderComplete() {   
 if (!Page.IsPostBack) {    
   foreach (GridItem item in MyGrid.MasterTableView.Controls[0].Controls) {      
      if (item is GridGroupHeaderItem)
        if (item.GroupIndex.ToString() != "0")
          item.Expanded = !item.Expanded;
    } 
  } 
}      
_畞蕅 2024-08-19 04:09:36

在 radGrid.DataBind() 之后

使用这个 Mehtod

private void ExpanadAllRadGridNodes()
        {
            foreach (GridDataItem item_L1 in radgridQuestionGroups.MasterTableView.Items)
            {
                foreach (GridTableView item_L2 in (item_L1 as GridDataItem).ChildItem.NestedTableViews)
                {
                    foreach (GridDataItem item_L3 in item_L2.Items)
                    {
                        item_L3.Expanded = true;
                    }
                }
            }
        }

after radGrid.DataBind()

use this Mehtod

private void ExpanadAllRadGridNodes()
        {
            foreach (GridDataItem item_L1 in radgridQuestionGroups.MasterTableView.Items)
            {
                foreach (GridTableView item_L2 in (item_L1 as GridDataItem).ChildItem.NestedTableViews)
                {
                    foreach (GridDataItem item_L3 in item_L2.Items)
                    {
                        item_L3.Expanded = true;
                    }
                }
            }
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文