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

Accessing Child Grid's HScrollBar

2 Answers 88 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jeremy Murtishaw
Top achievements
Rank 1
Jeremy Murtishaw asked on 16 Feb 2010, 04:51 AM
Hello,

I need to access the HScrollBar element of a child grid to assign an event handler to the Scroll event. I am trying to do this programmatically in the ChildViewExpanded event handler for the grid. However, every time i try to reference e.ChildViewInfo.GridViewElement.HScrollBar, the GridViewElement object is null. Any help?

Also, I have a second issue. If the HScrollBar is enabled for the grid itself, and I scroll right, then click the + sign ahead of one of the rows, it does not open the child grid. Instead, it appears to select the cell that has scrolled underneath the row header column. This is undesirable for me. Is there some way that I can prevent the cell from getting selected and instead have the Child Grid expand?

Thanks!
Jeremy

2 Answers, 1 is accepted

Sort by
0
Accepted
Martin Vasilev
Telerik team
answered on 19 Feb 2010, 08:22 AM
Hello Jeremy Murtishaw,

Thank you for writing. You can subscribe to HScrollBar ValueChanged event in the grid ViewCellFormatting event. As to your second question, it is a known issue and it has already been fixed in latest release Q3 2009 SP1. However, you can still work-around it in older versions by setting GridGroupExpanderCellElement ZIndex property to some large value. Please, consider the following code:

void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement is GridDetailViewCellElement)
    {
        GridDetailViewCellElement detailsCell = (GridDetailViewCellElement)e.CellElement;
        if (detailsCell.Tag == null)
        {
            detailsCell.Tag = true;
            detailsCell.ChildTableElement.VScrollBar.ValueChanged += new EventHandler(VScrollBar_ValueChanged);
            detailsCell.ChildTableElement.HScrollBar.ValueChanged += new EventHandler(HScrollBar_ValueChanged);
        }
    }
  
    //fix for the click on expander cell (needed only in older versions)
    if (e.CellElement is GridGroupExpanderCellElement)
    {
        e.CellElement.ZIndex = 1000;
    }
}
  
void HScrollBar_ValueChanged(object sender, EventArgs e)
{
      
}
  
void VScrollBar_ValueChanged(object sender, EventArgs e)
{
  
}

Do not hesitate to contact me again if you have any other questions.

All the best,
Martin Vasilev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jeremy Murtishaw
Top achievements
Rank 1
answered on 19 Feb 2010, 05:56 PM
Hi Martin,

Both of your solutions worked perfectly. Just to let you know, I am currently running 2009 Q3 SP1, so it appears that may still be an issue in this version... However, the workaround is just fine.

Thanks!
Jeremy
Tags
GridView
Asked by
Jeremy Murtishaw
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Jeremy Murtishaw
Top achievements
Rank 1
Share this question
or