How do I change the width of parameter drop down box in SSRS?
Asked Answered
S

3

13

Is there a way to control the size of the parameter drop down box? In my current drop down box, the width increase according to the option with label of the longest length, in which causes my report's width to increase out of my control.

Thanks in advance.

Subjoin answered 5/3, 2013 at 23:46 Comment(0)
T
7

This is a frequent complaint. There is no simple way to control the parameter interface, such as changing the width of the boxes. You might be able to hack the html with some JavaScript. Or you can go full-on and build your own interface to collect the parameters and then call the SSRS report, either via web services or URL access.

Triumphal answered 6/3, 2013 at 15:23 Comment(0)
P
5

What I have found to work was use the LEFT function to set the length of the field. In my situation the description column of my parameter (Program Type) was defined as varchar(200) so the dropdown drawn was very wide. When I changed the SQL to

SELECT ProgramID, LEFT(Description, 25)... 

the dropdown was a better size, and the majority of the descriptions are less than 25 characters anyway.

Pustulate answered 27/11, 2013 at 15:28 Comment(2)
Any ideas for making the drop-down WIDER? (In my case, the labels are being truncated.) I've tried making the lable (and the value) longer than needed (using CONVERT(80), etc.), and tried adding trailing spaces or other trailing characters like "....." or even ".....x".Mallis
P.S. I finally found out that the problem I'm seeing -- with the parameter drop-down being not wide enough, to show the entire value -- only happens when a parameter is set to allow multiple values. And -- something I hadn't noticed -- when multiple values are allowed, the drop-down is resizable! social.msdn.microsoft.com/Forums/sqlserver/en-US/…Mallis
Y
0

I've had a look at this problem and it turns out that the value for the width is set programmatically, somehow, into a style for a div.

When the page is examined using Edge's DevTools, we can see that there is a hidden div in the mix that displays the associated drop down list for a particular control. This div contains another div nested in a span...

01 <div id="ReportViewerControl_ctl04_ctl03_divDropDown" 
02  onclick="event.cancelBubble=true;" 
03  onactivate="event.cancelBubble=true;" 
04  style="border-color: darkgray; border-width: 1px; border-style: solid; overflow: visible; background-color: window; display: inline; position: absolute; z-index: 11; left: 233px; top: 56px;">
05  <span style="margin: 0px; background-color: window;">
06      <div style="overflow: auto; width: 214px; height: 150px;">
07          <span>
                ...
                ...
08              <input type="hidden" 
09                  name="ReportViewerControl$ctl04$ctl03$divDropDown$ctl01$HiddenIndices" 
10                  id="ReportViewerControl_ctl04_ctl03_divDropDown_ctl01_HiddenIndices" value="36">
11          </span>
12      </div>
13      <div style="height: 16px; width: 100%; margin: 0px; border-top: 1px solid lightgray; background-color: window; direction: ltr;">
14          <img style="float: right; cursor: se-resize;" 
15            src="~snip~">
16      </div>
17  </span>
18 </div>

Line 06 is the important one - that contains the problem, which cannot be simply removed using CSS; the value of width: 214px; needs to be removed from the code.

If we edit this line and take out the width setting from the style element, the width of the multi-select box does resize to fit all elements.

The list does appear to be static, however, and generated for each drop down list.

SSRS appears to be based older WebForms technology. It's clear to see how the old controls seem to be influencing the way the code is written to the page. Instead of a lot of clean divs and flexigrids, we're looking at nested tables and iframes. On top of that, the HTML is piped into form tag on an aspx page in the background (C:\Program Files\Microsoft SQL Server Reporting Services\SSRS\ReportServer\Pages\ReportViewer.aspx).

This is useful in some respects, as the ReportViewer.aspx file can be edited and we can add our own JS to handle this problem.

I'm busy trying to modify this at the moment to re-write the value, so I'll keep you posted....

Yun answered 19/5, 2023 at 17:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.