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

Need to set scrollbar dynamically to childgrid in hierarchy gridview

7 Answers 82 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ravi
Top achievements
Rank 1
Ravi asked on 13 Apr 2011, 01:37 PM
Hi,

I do have a requirement, I have implemented a hierarchical datagridview, i have lots of data in some child grid and few data on some childgrid, now if the childgrid has more than 5 rows i want to have the vertical scrollbar enabled otherwise it should not have the scrollbar.

my issue, if the set the height of the grid as some 100, its getting set for all the grid, irrespective of whether data is there or not. which i dont want.

What i finally want is, if there are more than 5 rows, show 5 rows and enable the scrollbar. if there are less than 5 rows, the child grid placeholder should exactly fit in, the child grid place holder should not show the height of 5 rows.

Thanks,
Shiras

7 Answers, 1 is accepted

Sort by
0
Ravi
Top achievements
Rank 1
answered on 15 Apr 2011, 01:59 PM
Please do let me know if you have any updates for this.
0
Pavel Pavlov
Telerik team
answered on 18 Apr 2011, 09:58 AM
Hello David,

This may be hard to achieve , but not impossible .
I think I found a solution :

You may bind the height of the GridView to the items/ items count in the source .

You will need to implement a custom IValueConverter for this binding . Then inside the convert method you may check the items count.
In case rows are more than 5 - return a fixed height e.g. 100 , in case rows are less than 5 - return Auto height.

In case you have troubles implementing this ,just let me know and I will provide a small working sample for you .

Best wishes,
Pavel Pavlov
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
Ravi
Top achievements
Rank 1
answered on 18 Apr 2011, 12:49 PM
Thanks for your great idea, Appreciate it.

Can you please provide me a working sample, As it will help me a lot.

Thanks,
Shiras
0
Ravi
Top achievements
Rank 1
answered on 19 Apr 2011, 05:21 PM
Can you please provide a sample project as a reply to this post?

Thanks
0
Ravi
Top achievements
Rank 1
answered on 20 Apr 2011, 02:02 PM
Appreciate your early response.

Thanks
0
Pavel Pavlov
Telerik team
answered on 21 Apr 2011, 02:34 PM
Hello David,
Please excuse me for the delayed answer, I am preparing a sample for you right now  and will send it as soon as it is ready ( later today ) .

Regards,
Pavel Pavlov
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
Accepted
Pavel Pavlov
Telerik team
answered on 21 Apr 2011, 03:15 PM
Hello David,

While preparing the sample for you  I found even an easier and strightforward way .

Setting just the MaxHeight property of the child grid should do the trick .  I have demonstrated this in the sample attached.

Child grids with more than 2 rows will show up vertical scrollbars. ( To have this adjusted to your requirement of 5 rows - just increase the value of MaxWidth).

Regards,
Pavel Pavlov
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
Tags
GridView
Asked by
Ravi
Top achievements
Rank 1
Answers by
Ravi
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or