7 Answers, 1 is accepted
0
Hello Maarten,
Thank you for writing.
You can achieve that by using the ChildViewExpanded event in co-operation with GridTraverser in the following manner:
I hope this helps.
Greetings,
Svett
the Telerik team
Thank you for writing.
You can achieve that by using the ChildViewExpanded event in co-operation with GridTraverser in the following manner:
void
radGridView1_ChildViewExpanded(
object
sender, Telerik.WinControls.UI.ChildViewExpandedEventArgs e)
{
GridRowElement rowElement =
this
.radGridView1.TableElement.GetRowElement(e.ChildRow);
if
(rowElement !=
null
)
{
GridTraverser traverser =
new
GridTraverser(
this
.radGridView1.TableElement.RowScroller.Traverser
as
GridTraverser);
traverser.ProcessHierarchy =
true
;
traverser.Reset();
int
value = 0;
while
(traverser.MoveNext())
{
if
(traverser.Current.PinPosition == PinnedRowPosition.None)
{
value +=
this
.radGridView1.TableElement.ViewElement.RowLayout.GetRowHeight(traverser.Current);
}
if
(traverser.Current == e.ParentRow)
{
break
;
}
}
RadScrollBarElement vScroll =
this
.radGridView1.TableElement.VScrollBar;
if
(value < vScroll.Minimum)
{
value = vScroll.Minimum;
}
if
(value > vScroll.Maximum)
{
value = vScroll.Maximum;
}
vScroll.Value = value;
}
}
I hope this helps.
Greetings,
Svett
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Maarten
Top achievements
Rank 1
answered on 17 Sep 2012, 01:10 PM
Hi,
Thx for the code example!
However I noticed two items:
- The example only works correct if only one row is expanded. If a user already expanded one row and expands a second the rowheight calculation is no longer correct. Is there a method to calculate the rowheight taking into account the subgrid height?
- If a user selects the + sign to expand a row this parent row is moved to the top but is no longer selected. For the user quite confusing... I already tried to force the parentrow to be the selected one but I think another event counteracts this. Any ideas?
Many thx!
Maarten
Thx for the code example!
However I noticed two items:
- The example only works correct if only one row is expanded. If a user already expanded one row and expands a second the rowheight calculation is no longer correct. Is there a method to calculate the rowheight taking into account the subgrid height?
- If a user selects the + sign to expand a row this parent row is moved to the top but is no longer selected. For the user quite confusing... I already tried to force the parentrow to be the selected one but I think another event counteracts this. Any ideas?
Many thx!
Maarten
0
Hello Maarten,
Regarding your questions:
1. I did not manage to reproduce the issue. I am enclosing a recorded video that demonstrates my approach. Could you point me what I missed? Note that you need installed web browser and flash plugin to watch it.
2. You should modify the ChildViewExpanded event handler in the following way to make the expanded row current:
Regards,
Svett
the Telerik team
Regarding your questions:
1. I did not manage to reproduce the issue. I am enclosing a recorded video that demonstrates my approach. Could you point me what I missed? Note that you need installed web browser and flash plugin to watch it.
2. You should modify the ChildViewExpanded event handler in the following way to make the expanded row current:
void
radGridView1_ChildViewExpanded(
object
sender, Telerik.WinControls.UI.ChildViewExpandedEventArgs e)
{
GridRowElement rowElement =
this
.radGridView1.TableElement.GetRowElement(e.ChildRow);
if
(rowElement !=
null
)
{
GridTraverser traverser =
new
GridTraverser(
this
.radGridView1.TableElement.RowScroller.Traverser
as
GridTraverser);
traverser.ProcessHierarchy =
true
;
traverser.Reset();
int
value = 0;
while
(traverser.MoveNext())
{
if
(traverser.Current.PinPosition == PinnedRowPosition.None)
{
value +=
this
.radGridView1.TableElement.ViewElement.RowLayout.GetRowHeight(traverser.Current);
}
if
(traverser.Current == e.ParentRow)
{
break
;
}
}
RadScrollBarElement vScroll =
this
.radGridView1.TableElement.VScrollBar;
if
(value < vScroll.Minimum)
{
value = vScroll.Minimum;
}
if
(value > vScroll.Maximum)
{
value = vScroll.Maximum;
}
vScroll.Value = value;
e.ParentRow.IsCurrent =
true
;
}
}
Regards,
Svett
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Wesley
Top achievements
Rank 1
answered on 24 Sep 2012, 09:32 AM
I think the problem in the proposed solution is that the scroll position is calculated by adding the height of data rows.
The following heights are not included:
The following heights are not included:
- header row height of subgrid
- filter row height of subgrid
- padding/margin around subgrid
- ... ??
So when you start to expand multiple rows, the calculated scroll position gets more and more out of position
0
Hi Wesley,
You do not need to include the height of the header and filter rows, because they are pinned rows. Hence, they do not determine the scroll bar calculation. Regarding, the padding/margin values are included in the row height.
Greetings,
Svett
the Telerik team
You do not need to include the height of the header and filter rows, because they are pinned rows. Hence, they do not determine the scroll bar calculation. Regarding, the padding/margin values are included in the row height.
Greetings,
Svett
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Wesley
Top achievements
Rank 1
answered on 28 Sep 2012, 01:27 PM
Hi,
I think the height of the pinned rows of the child grids need to be included. Only the pinned rows of the main grid can be excluded.
I do this by traversing all row types and only counting the height of a pinned row if its hierarchy is greather than 1:
This produced a better result, but there still is a problem:
An inner grid can also have a scrollbar on its own (see screenshot). The code above will add the heigth of all rows of the inner grid instead of excluding invisible rows (due to the inner scrollbar). This results in a scroll position that is wrong.
I think that if it would be possible to get the actual height of a row including its child rows, I would be able to implement what I want
I think the height of the pinned rows of the child grids need to be included. Only the pinned rows of the main grid can be excluded.
I do this by traversing all row types and only counting the height of a pinned row if its hierarchy is greather than 1:
void
TransactionGridViewChildViewExpanded(
object
sender, ChildViewExpandedEventArgs e)
{
//Make sure an expanded row is shown on top.
if
(!e.IsExpanded)
return
;
var traverser =
new
GridTraverser(transactionGridView.TableElement.RowScroller.Traverser
as
GridTraverser) { ProcessHierarchy =
true
, TraversalMode = GridTraverser.TraversalModes.AllRows };
traverser.Reset();
int
value = 0;
while
(traverser.MoveNext())
{
if
(traverser.Current == e.ParentRow)
{
break
;
}
if
(traverser.Current.PinPosition == PinnedRowPosition.None || traverser.Current.HierarchyLevel > 1)
{
value += transactionGridView.TableElement.ViewElement.RowLayout.GetRowHeight(traverser.Current);
}
}
RadScrollBarElement vScroll = transactionGridView.TableElement.VScrollBar;
if
(value < vScroll.Minimum) value = vScroll.Minimum;
if
(value > vScroll.Maximum) value = vScroll.Maximum;
vScroll.Value = value;
e.ParentRow.IsCurrent =
true
;
}
This produced a better result, but there still is a problem:
An inner grid can also have a scrollbar on its own (see screenshot). The code above will add the heigth of all rows of the inner grid instead of excluding invisible rows (due to the inner scrollbar). This results in a scroll position that is wrong.
I think that if it would be possible to get the actual height of a row including its child rows, I would be able to implement what I want
0
Hi Maarten,
Unfortunately, the proposed solution does not work for more than two levels of hierarchy. I have tried to change it in a way to support all levels of hierarchy, but due to the dynamic calculations of the elements sizes during scrolling I was not able to do that.
Kind regards,
Svett
the Telerik team
Unfortunately, the proposed solution does not work for more than two levels of hierarchy. I have tried to change it in a way to support all levels of hierarchy, but due to the dynamic calculations of the elements sizes during scrolling I was not able to do that.
Kind regards,
Svett
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>