This is a migrated thread and some comments may be shown as answers.

Self Hiearchy not working on subsequent pages

1 Answer 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 06 Dec 2012, 06:19 PM
Hi,
 We have an application that's been in production for over a year. Basically, it manages open tickets.
 Apparently this is the first time we've had more than 20 open tickets where tickets appearing on the 2nd page had child tickets.

The problem is that - when the page is changed the Self Hierarchy breaks down and the grid does not recognize a ticket as a parent ticket, and therefore it's child tickets are unavailable.

I use a recursive function that is passed a GridTableView that grabs an array of nestedVieItems and determines whether they have any children, and if so it will add the button to allow them to be visible and it changes the styling.

basically the problem is that the MasterTableView does not contain nestedviewitems for items that aren't on the first page.
If I set the PageSize = aNumber > numberOfTickets, then everything works as expected, its when the pagesize is set to a number less than the number of tickets and a ticket on the second page has children, that we have an issue.

Oh - and if I change the code to have the expand/collapse button always visible, when I click it next to an item on the 2nd page that I know has children - it says: "No child records to display". So I guess the issue isn't with either of the 2 below subroutines, its that the RadGrid doesn't think that any of my items on a Page that is not the first page has any children.

Below is the code i use to hide/show the ExpandCollapse button and set the style of the row.

public void Page_PreRenderComplete(object sender, EventArgs e)
{
      
    if(btnToggleHierarchy.Checked)
        HideExpandColumnRecursive(RadGrid1.MasterTableView);
       
}
/// <summary>
/// Create buttons on items that have children
/// </summary>
/// <param name="tableView"></param>
public void HideExpandColumnRecursive(GridTableView tableView)
{
    GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
    foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
    {
        foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
        {
            nestedView.Style["border"] = "0";
            Button MyExpandCollapseButton = (Button)nestedView.ParentItem.FindControl("MyExpandCollapseButton");
            if (nestedView.Items.Count == 0)
            {
                if (MyExpandCollapseButton != null)
                {
                    MyExpandCollapseButton.Style["visibility"] = "hidden";
                    ((TableCell)MyExpandCollapseButton.Parent).BackColor = System.Drawing.Color.White;
                }
                nestedViewItem.Visible = false;
            }
            else
            {
                if (MyExpandCollapseButton != null)
                {
                    //Only set the background if we are the Highest Parent... otherwise leave it to the
                    //alternating styles
                    if (nestedView.ParentItem.OwnerTableView == RadGrid1.MasterTableView)
                        ((TableCell)MyExpandCollapseButton.Parent).CssClass = "ExpandCollapseBackground" ;
                      
                    MyExpandCollapseButton.Style.Remove("visibility");
                }
            }
            if (nestedView.HasDetailTables)
            {
                HideExpandColumnRecursive(nestedView);
            }
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 11 Dec 2012, 10:04 AM
Hello Patrick,

The provided code seems to be correct on a first glance. Could you please elaborate a little bit more on your scenario? Sending us your markup with the related code behind will help us to pinpoint the reason for this behavior.

All the best,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Patrick
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or