How to set the minimum width of a column while AllowColumnResize is set to "True"

7 posts, 0 answers
  1. Sudha
    Sudha avatar
    27 posts
    Member since:
    May 2011

    Posted 14 Nov 2011 Link to this post

    Hi,

    AllowColumnResize

     

     

    ="True" in the rad gird. This allows resizing the columns to any width. I want to set a minimum value to which the column width can be reduced. if the user tries to reduce the width of the column lower than what is specified , then the width should be set to the minimum value mentioned.

    Kindly let us know if this can be achieved and how.

    Thanks,
    Sudha.

  2. Kiara
    Kiara avatar
    309 posts
    Member since:
    Jul 2006

    Posted 14 Nov 2011 Link to this post

    I would set HeaderStyle > Width for the column in question, Sudha. I think that in this way you should be able to define minwidth for the column when resized.

    Kiara
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sudha
    Sudha avatar
    27 posts
    Member since:
    May 2011

    Posted 15 Nov 2011 Link to this post

    Thanks.
    But we have the width set in the HeaderStyle. It is not working.
  5. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 15 Nov 2011 Link to this post

    Hello,

    It was not possible but try with below code snippet.
    It was not exactly fulfill your requirement but its helpful to you.

    function ColumnResizing(sender, eventArgs) {
                 if (eventArgs._gridColumn._data.UniqueName == "YourColumnUNiqueName" && eventArgs.get_gridColumn()._columnResizer._currentWidth < 100) {
                     eventArgs._cancel = true;
                 }
             }
    <ClientEvents  OnColumnResizing="ColumnResizing" />


    Thanks,
    Jayesh Goyani
  6. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 15 Nov 2011 Link to this post

    Hi Sudha,

    You cannot set min/max column widths, but you can use the ColumnResizing client event to check what the new column width would be and cancel/modify it:

    http://www.telerik.com/community/forums/aspnet-ajax/grid/allowcolumnresize---can-a-minimum-column-size-be-enforced.aspx

    After cancelling the event, you can resize the column to a preferred min/max width with the control's API -

    http://demos.telerik.com/aspnet-ajax/grid/examples/client/clientsideapi/defaultcs.aspx

    http://www.telerik.com/help/aspnet-ajax/grid-resizing-columns.html

    Kind regards,
    Pavlina
    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
  7. Sudha
    Sudha avatar
    27 posts
    Member since:
    May 2011

    Posted 15 Nov 2011 Link to this post

    Using this code , i am getting an exception that the

    ._columnResizer is null.
    How to resolve this ? Please help.

  8. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 15 Nov 2011 Link to this post

    Hello,

    function ColumnResizing(sender, eventArgs) {
                   
                   if (eventArgs._gridColumn._data.UniqueName == "ColumnUniqueName" && eventArgs._gridColumn._columnResizer._currentWidth < 100) {
                       eventArgs._cancel = true;
                   }
               }

    for more information please check this link.

    Thanks,
    Jayesh Goyani
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017