Hi,
I am developing a windows application using radGrid (Hierarchical grid). I want to see only 5 child records at a time when parent row is expanded. Currently I have 50 child records and All the child records are getting displayed. I want to restrict the number of child records to be viewed, So that the remaining records can be scrolled.
Please suggest me if we can achieve this.
Thanks
Hari Kumar
I am developing a windows application using radGrid (Hierarchical grid). I want to see only 5 child records at a time when parent row is expanded. Currently I have 50 child records and All the child records are getting displayed. I want to restrict the number of child records to be viewed, So that the remaining records can be scrolled.
Please suggest me if we can achieve this.
Thanks
Hari Kumar
4 Answers, 1 is accepted
0
Hi Hari,
You can restrict the child view height by setting the MaxHeight property when handling the ChildViewExpanded property. Please take a look at the sample below:
I hope this helps. Please write me back, If you have other questions.
Regards,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
You can restrict the child view height by setting the MaxHeight property when handling the ChildViewExpanded property. Please take a look at the sample below:
void radGridView1_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e) |
{ |
e.ChildRow.MaxHeight = 300; |
} |
I hope this helps. Please write me back, If you have other questions.
Regards,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Hari
Top achievements
Rank 1
answered on 11 Jun 2009, 12:22 PM
Hi Jack,
Thanks for your quick response. I tried with your code.It is working fine, But When I test in different resolution, The last record is not displaying completely. The bottom border line of the last row of the child view is not displaying.
Can you provide me the generalized solution for any resolution?
For Example,
Some thing like below:
e.ChildRow.MaxHeight = (gridRowheight * no.of records to be displayed)
Thanks
Hari
Thanks for your quick response. I tried with your code.It is working fine, But When I test in different resolution, The last record is not displaying completely. The bottom border line of the last row of the child view is not displaying.
Can you provide me the generalized solution for any resolution?
For Example,
Some thing like below:
e.ChildRow.MaxHeight = (gridRowheight * no.of records to be displayed)
Thanks
Hari
0
Hi Hari,
Please, consider the following code snippet:
In this example, CalcHeight function calculates the height of the second level of the RadGridView hierarchy. It takes into consideration the height of every element, such as filter row, horizontal scrollbar, vertical padding, etc. By setting value to (int)i variable, you can control the number of displayed rows. Please, do not forget to subscribe to ChildViewExpanded event.
I hope this helps. Please, let me know if you have further questions.
All the best,
Boryana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Please, consider the following code snippet:
void radGridView1_ChildViewExpanded(object sender, Telerik.WinControls.UI.ChildViewExpandedEventArgs e) |
{ |
if (e.IsExpanded) |
{ |
e.ChildRow.Height = CalcHeight(e.ChildViewInfo); |
} |
} |
private int CalcHeight(GridViewInfo viewInfo) |
{ |
int height = 0; |
int i = 0; |
foreach (GridViewDataRowInfo rowInfo in viewInfo.Rows) |
{ |
if (i < 5) |
{ |
height += rowInfo.GetActualHeight(radGridView1.GridElement); |
if (rowInfo.IsExpanded) |
{ |
height += CalcHeight(rowInfo.ChildRow.ChildViewInfo); |
} |
i++; |
} |
} |
if (viewInfo.ViewTemplate.ShowColumnHeaders) |
{ |
height += viewInfo.TableHeaderRow.GetActualHeight(radGridView1.GridElement); |
} |
if (viewInfo.ViewTemplate.EnableFiltering) |
{ |
height += viewInfo.TableFilteringRow.GetActualHeight(radGridView1.GridElement); |
} |
if (viewInfo.ViewTemplate.AllowAddNewRow) |
{ |
height += viewInfo.TableAddNewRow.GetActualHeight(radGridView1.GridElement); |
} |
//horizontal scrollbar |
height += 20; |
// vertical padding |
height += 20; |
return height; |
} |
In this example, CalcHeight function calculates the height of the second level of the RadGridView hierarchy. It takes into consideration the height of every element, such as filter row, horizontal scrollbar, vertical padding, etc. By setting value to (int)i variable, you can control the number of displayed rows. Please, do not forget to subscribe to ChildViewExpanded event.
I hope this helps. Please, let me know if you have further questions.
All the best,
Boryana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Hari
Top achievements
Rank 1
answered on 15 Jun 2009, 01:02 PM
Hi Boryana,
Thank you for your valuable solution. I could able to achieve the required functionality with little modifications.
I have changed 'height' variable value to -2. It is working fine for me.
Thanks
Hari
Thank you for your valuable solution. I could able to achieve the required functionality with little modifications.
I have changed 'height' variable value to -2. It is working fine for me.
Thanks
Hari