【问题标题】:RadGridView get child template data?RadGridView 获取子模板数据?
【发布时间】:2016-01-15 01:43:15
【问题描述】:

我试图在遍历网格时仅获取子模板的数据。

我从这个开始:

        foreach (GridViewRowInfo row in radGridView1.Rows)
        {
            err = IterateChildRows(row);
        }

并将行传递给此:

    private bool IterateChildRows(GridViewRowInfo rowInfo)
    {
        bool err = false;
        if (rowInfo.Cells[5].Value != null && rowInfo.Cells[5].Value.ToString() != "01/01/1900")
        {
            if (rowInfo.Cells[0].ViewTemplate.Templates[0].Caption == "Current")
            {
                if (rowInfo.ViewTemplate.Templates[0].RowCount == 0)
                {
                    MessageBox.Show("Not all products have CURRENT quantity breaks", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    err = true;
                }
            }
        }
        return err;
     }

我的问题是我似乎无法找到我传入的行的子模板数据。我尝试的所有内容似乎都有来自所有主模板项的所有子行,而不仅仅是我传入的行.

因此,如果我的主网格中有 2 个项目,子模板中有 3 个项目,那么我的计数是 6 而不是 3。

我不知道我哪里错了......

有人吗?

干杯 院长

【问题讨论】:

    标签: c# telerik-grid radgrid radgridview


    【解决方案1】:

    试试下面的方法,子行可以通过 HierarchyRowInfo 访问

    private bool IterateChildRows(GridViewRowInfo rowInfo)
    {
        bool err = false;
        GridViewHierarchyRowInfo hierarchyRow = rowInfo as GridViewHierarchyRowInfo;
    
        //To get current row childRows count
        int noOfChildRows = hierarchyRow.ChildRows.Count;
    
        //looping through the child rows
        foreach (GridViewRowInfo row in hierarchyRow.ChildRows)
        {   
            //check if its current child row
            if(row.IsCurrent)
            {
               // Do your logic
            }
        }
    
        return err;
     }
    

    【讨论】:

    • 谢谢巴耶尼 - 我已经找了一个星期了......这正是我所追求的:)
    • 我很高兴能得到帮助 :)
    猜你喜欢
    • 2012-09-26
    • 2012-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多