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

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

6 Answers 849 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sudha
Top achievements
Rank 1
Sudha asked on 14 Nov 2011, 12:14 PM
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.

6 Answers, 1 is accepted

Sort by
0
Kiara
Top achievements
Rank 1
answered on 14 Nov 2011, 12:51 PM
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
0
Sudha
Top achievements
Rank 1
answered on 15 Nov 2011, 07:12 AM
Thanks.
But we have the width set in the HeaderStyle. It is not working.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 15 Nov 2011, 10:18 AM
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
0
Pavlina
Telerik team
answered on 15 Nov 2011, 10:19 AM
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
0
Sudha
Top achievements
Rank 1
answered on 15 Nov 2011, 11:45 AM
Using this code , i am getting an exception that the

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

0
Jayesh Goyani
Top achievements
Rank 2
answered on 15 Nov 2011, 11:59 AM
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
Tags
Grid
Asked by
Sudha
Top achievements
Rank 1
Answers by
Kiara
Top achievements
Rank 1
Sudha
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Pavlina
Telerik team
Share this question
or