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

[Solved] ForeignKey, How to set the width of the drop down?

6 Answers 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
bbeatty
Top achievements
Rank 1
bbeatty asked on 05 Apr 2012, 05:19 PM
I have a grid with a  ForeignKey column. Its a wide grid to allow for the text of the drop down.
But the drop down itself is narrow.
How can I adjust the width of the ForeignKey drop down, so I do not have multiple lines displayed in the drop down.
I know I can set the .DropDownHtmlAttributes(new { style = "width:300px" })  on a drop down list.
But how can I change it when its a ForeignKey Column?

Can the width be adjustable based on the data ? I don't want multiple lines for an item in the list.
I've attached a screen shot of the problem.
 


6 Answers, 1 is accepted

Sort by
0
Dadv
Top achievements
Rank 1
answered on 06 Apr 2012, 02:08 PM
Use the OnEdit event and jquery to add a css style (or better a new css class)
0
bbeatty
Top achievements
Rank 1
answered on 06 Apr 2012, 03:24 PM
Which object would I set the css class?
Can you supply an example?
Thanks
0
Accepted
Dadv
Top achievements
Rank 1
answered on 06 Apr 2012, 03:31 PM
try something like this :

function onEdit(e)
{
var row = e.row;
$(row).find('.t-dropdown').css('width','300px');
//or better : $(row).find('.t-dropdown').addClass('myClass'); 
}
0
Rajesh
Top achievements
Rank 1
answered on 09 Apr 2012, 07:08 AM
What if there are multiple foreign key columns? which item of class "t-dropdown" will be retrieved?
0
Dadv
Top achievements
Rank 1
answered on 10 Apr 2012, 08:48 AM
This is more a jQuery question then look at this
0
Rajesh
Top achievements
Rank 1
answered on 13 Apr 2012, 09:05 AM
OK, a Telerik question - 

If i change the width of the t-dropdown using jquery, it also resizes the grid columns. What i want is the drop down items to not wrap around - and they are <li>s in a t-animation-container, that is not present when OnEdit fires. AFAIK, the telerik dropdown does not expose any jquery event onDropDown (or the like). So how do is set the width of the t-animation-container and/or t-popu t-group corresponding to the t-drop-down.
Tags
Grid
Asked by
bbeatty
Top achievements
Rank 1
Answers by
Dadv
Top achievements
Rank 1
bbeatty
Top achievements
Rank 1
Rajesh
Top achievements
Rank 1
Share this question
or