Need to set scrollbar dynamically to childgrid in hierarchy gridview

8 posts, 1 answers
  1. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 13 Apr 2011 Link to this post

    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
  2. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 15 Apr 2011 Link to this post

    Please do let me know if you have any updates for this.
  3. DevCraft banner
  4. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 18 Apr 2011 Link to this post

    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
  5. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 18 Apr 2011 Link to this post

    Thanks for your great idea, Appreciate it.

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

    Thanks,
    Shiras
  6. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 19 Apr 2011 Link to this post

    Can you please provide a sample project as a reply to this post?

    Thanks
  7. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 20 Apr 2011 Link to this post

    Appreciate your early response.

    Thanks
  8. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 21 Apr 2011 Link to this post

    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
  9. Answer
    Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 21 Apr 2011 Link to this post

    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
Back to Top
DevCraft banner