purtuga / SPWidgets

Sharepoint Custom UI Widgets
74 stars 34 forks source link

Question: SPControlLookupField width? #45

Open seanmarthur opened 9 years ago

seanmarthur commented 9 years ago

Hi,

I have a user request to increase the width of the lookup field to prevent options from wrapping in the selection dropdown. I looked through the documentation for some kind of option or setting to handle this but couldn't find anything. Ideally I would like the width to be dynamically set such that none of the results of the lookup target list wrap.

Crude example: lookup wrapping

I've figured out that I can just hard-set a css width on the top-level div with the class 'spwidgets-lookup-cntr' to change the width of the control, but I'd rather not have to keep adjusting it if wider and wider content gets added to the lookup list.

Do you have any suggestions on achieving this?

purtuga commented 9 years ago

I been meaning to refactor this widget.  I too don't like the way the chooser presents the possible values and have also run up against the condition where the choices are wrapped and I can't figure out where one ends and the other begins.  Since you are the first one that has reported an issue against this widget, I now have an incentive to do it sooner rather than later.  :) As you already figured out, the only way to currently do it is to manipulated the element of the entire widget.   I don't think this will work, but try to set the with of a selector called ".spwidget-lookup-selector-cntr" to something like 600px (or more of you need to).  That's the actual DIV that shows the lookup list values.  I say it will not work because currently that element is inside of the container for the entire widget. In order for it to work as you request, I'll have to move it to the root of the document body. I'll take note of your request and the next time I touch this widget I'll introduce a way for you to define the width of the selector popup.  Making the default width "as long as the content" is not good idea because the values could very long and just scroll off the page. The right approach is to let the developer define it on input. 

Paul -- sent from mobile

seanmarthur commented 9 years ago

Setting that '.spwidget-lookup-selector-cntr' actually works quite well! it allows the control to stay compact, and just the drop-down be wider: servicewiden

I will use this. Thanks for the suggestion.

purtuga commented 9 years ago

Ok. Good (for now). Just keep in mind that works as long as the parent element to the widget is wide enough. 

Paul -- sent from mobile