Setting a minimum width on column

12 posts, 0 answers
  1. Joakim Nilsson
    Joakim Nilsson avatar
    6 posts
    Member since:
    Dec 2009

    Posted 29 Jun 2010 Link to this post

    Hi,

    I have a radgrid that is flexible in width. All columns except one has a defined headerstyle-width. The column without width is supposed to claim all width that is available depending on how wide the screen of the user is.

    My problem is that if the user resizes his/hers window to small the column without width specified gets the width 0 and is not visible to the user. I want to set a minimum width of that column.

    How do I go about doing this?

    /Joakim
  2. Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 29 Jun 2010 Link to this post

    Hello Joakim,

    Unfortunately table columns do not support minimum width, so it will be easier for you to set a min-width CSS style to the RadGrid control.

    Sincerely yours,
    Dimo
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Joakim Nilsson
    Joakim Nilsson avatar
    6 posts
    Member since:
    Dec 2009

    Posted 29 Jun 2010 Link to this post

    Could you give an example?

    Thanks!

    /Joakim
  5. Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 29 Jun 2010 Link to this post

    <telerik:RadGrid  style="min-width:800px"  />

    Note that the min-width style is not supported by IE6. If you must support this browser as well, then you can subscribe to the browser window resize event, get the RadGrid width (gridClientObject.get_element().offsetWidth) and set a larger one if needed with

    (Javascript)

    gridClientObject.get_element().style.width = "800px";
    gridClientObject.repaint(); // if you are using scrolling with static headers

    http://www.telerik.com/help/aspnet-ajax/grdgettingradgridclientobject.html


    Regards,
    Dimo
    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
  6. John
    John avatar
    44 posts
    Member since:
    Apr 2011

    Posted 05 Mar 2012 Link to this post

    We need to set a minimum width on each column since if a user resizes the column too small, it cannot be recovered without a full refresh.  Is there some way to set the minimum width of each column somehow?
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Mar 2012 Link to this post

    Hello John,

    Check the following demo.
    Grid / Column/Row Resize/Reorder

    -Shinu.
  8. John
    John avatar
    44 posts
    Member since:
    Apr 2011

    Posted 06 Mar 2012 Link to this post

    Setting a minimum width on the grid as a whole does nothing to prevent the userfrom making a column disappear by dragging the column size bar too far.  What is needed is a minimum width on the column.
  9. John
    John avatar
    44 posts
    Member since:
    Apr 2011

    Posted 06 Mar 2012 Link to this post

    I cannot get that demo to actually allow resizing of the columns.  We do want the columns to be resizable, but not to zero width.
  10. Galin
    Admin
    Galin avatar
    526 posts

    Posted 08 Mar 2012 Link to this post

    Hi John,

    You can achieve this with the following JavaScript function
    function ColumnResizing(sender, args)
    {
        if (args.get_gridColumn()._columnResizer._currentWidth < 200)
        {
            args.set_cancel(true);
        }
    }

    I hope this helps.

    All the best,
    Galin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  11. Xavier
    Xavier avatar
    29 posts
    Member since:
    Jun 2014

    Posted 02 May 2015 in reply to Galin Link to this post

    Could you please give the TypeScript version of this code?

    When I tried your code, I get TypeScript error

    "

    Types of property 'columnResize' are incompatible.
        Type '(sender: any, args: any) => void' is not assignable to type '(e: GridColumnResizeEvent) => void'

    "

  12. Galin
    Admin
    Galin avatar
    526 posts

    Posted 07 May 2015 Link to this post

    Hi Xavier,

    Attached to this post you can find a sample web page demonstrating the suggested approach. Please examine it and let me know how it goes.

    Regards,
    Galin
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  13. Xavier
    Xavier avatar
    29 posts
    Member since:
    Jun 2014

    Posted 08 May 2015 in reply to Galin Link to this post

    Cool, thanks.

    My mistake. I am using Kendo UI grid so I will post a separate question on it.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017