auto fit based on grid contents

4 posts, 0 answers
  1. Kip
    Kip avatar
    7 posts
    Member since:
    Sep 2009

    Posted 16 Dec 2009 Link to this post

    With DevExpress, when I drop a gridview control into a page with no width setting the grid will size itself according to header/row contents.

    With Telerik, the gridview with no width property configured will expand to 100% of the width of the container it's in. I do not want to configure the width. I looked through several forum posts here and was unable to find a solution. Although I did attempt to change several settings while searching for a solution, this happens with all properties set to their default values.

  2. Dimo
    Admin
    Dimo avatar
    7423 posts
    Member since:
    Sep 2012

    Posted 17 Dec 2009 Link to this post

    Hi Kip,

    Indeed, RadGrid expands itself to 100% by default, because its wrapper element is a <div> and not a <table>. Here is how to make the control shrink, according to its content:

    http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-defaults-to-100-wide.aspx


    Kind regards,
    Dimo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  3. Kip
    Kip avatar
    7 posts
    Member since:
    Sep 2009

    Posted 17 Dec 2009 Link to this post

    Dimo,
    Thanks... That solution works great. The main reason I use these controls is due to my lack of experience with the web piece... allows rapid development for native programmers.

    One question, when using the css fix if I enable the scrolling option the control again expands to 100% width, how would I make it auto fit based on the contents with scrolling enabled? I'm really looking for a way to make this the default behavior... I don't want it expanding to 100% unless I specifically set the width property to 100%.

  4. Dimo
    Admin
    Dimo avatar
    7423 posts
    Member since:
    Sep 2012

    Posted 17 Dec 2009 Link to this post

    Hello Kip,

    The concept of scrolling in CSS is tightly connected to some fixed size. Scrolling with auto-fitting content does not make much sense. Scrolling occurs when a child element is larger than its scrollable container. If the latter has no explicit dimensions, how will the browser determine how large the scrollable container should be?


    Best wishes,
    Dimo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

Back to Top