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

Setting a minimum width on column

11 Answers 1568 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joakim Nilsson
Top achievements
Rank 1
Joakim Nilsson asked on 29 Jun 2010, 09:03 AM
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

11 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 29 Jun 2010, 12:58 PM
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
0
Joakim Nilsson
Top achievements
Rank 1
answered on 29 Jun 2010, 01:41 PM
Could you give an example?

Thanks!

/Joakim
0
Dimo
Telerik team
answered on 29 Jun 2010, 02:14 PM
<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
0
John
Top achievements
Rank 1
answered on 05 Mar 2012, 06:16 PM
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?
0
Shinu
Top achievements
Rank 2
answered on 06 Mar 2012, 05:59 AM
Hello John,

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

-Shinu.
0
John
Top achievements
Rank 1
answered on 06 Mar 2012, 02:12 PM
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.
0
John
Top achievements
Rank 1
answered on 06 Mar 2012, 02:16 PM
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.
0
Galin
Telerik team
answered on 08 Mar 2012, 05:02 PM
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.
0
Xavier
Top achievements
Rank 1
answered on 02 May 2015, 05:41 PM

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'

"

0
Galin
Telerik team
answered on 07 May 2015, 06:29 AM
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.

 
0
Xavier
Top achievements
Rank 1
answered on 08 May 2015, 05:43 PM

Cool, thanks.

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

Tags
Grid
Asked by
Joakim Nilsson
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Joakim Nilsson
Top achievements
Rank 1
John
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Galin
Telerik team
Xavier
Top achievements
Rank 1
Share this question
or