alanjuden / MvcReportViewer

Custom Report Viewer control to replace MS Report Viewer on MVC projects (also works on .NET Core as a Report Viewer).
MIT License
173 stars 109 forks source link

Set height / width when rendering #37

Open nhaberl opened 7 years ago

nhaberl commented 7 years ago

Hey, awesome work! Would like to ask if it is possible to set the height / width to the renderer so that it fits to my html block?

In the ReportViewer there is a property to set it.

alanjuden commented 7 years ago

Hey there @nhaberl, which height / width is it that you're referring too? If you're referring to the html container element that holds your report data I'm sure you could size it using css. If you're asking to change the dimensions of your report, you'll have to control that from SSRS. When you're designing your report you can set the sizing and it just comes through that size from the SSRS API and that's what is displayed from my code. I hope this helps!

Alan

nhaberl commented 7 years ago

What I mean is when I have a report width a ration 1:1 and 100 x 100 inches ... how can I achieve that this report fits into my 200x200px box on my website? (Or 300x300 and so on)

There is a need to scale down and in ReportViewer control you can set the height and width as paramters to the report which is to render and then the control scales it so it fits to the report container.

alanjuden commented 7 years ago

@nhaberl, you can control the width through CSS as I suggested above. I have just set the width in this rule of my .css class:

.ReportViewerHeader

The width is forced to 100% and if you drop that off or override it then you can control it.

nhaberl commented 7 years ago

Yes that's right for the header but I want that a report which renders in the size of 1000x1000px by example fits in a div tag which is 100x100px ... so I need a way that I can request that report in 100x100px not 1000x1000px respectively.

No scrollbars and so on ... the content should fit into the target div.

alanjuden commented 7 years ago

@nhaberl, I believe I understand what you're saying but when I run the report on my test server and don't have the width specified in the .css file, the outside of the report viewer shrinks down to fit the size. Have you tried it without the .css rule I mentioned and it wasn't functioning for you as expected?

nhaberl commented 7 years ago

yes that's right ... but think the way around ... the rendered report is bigger than the viewer ... thewn scrollbars appear in the viewer and I would like to achieve that thé report scales down so it fits into the viewer

alanjuden commented 7 years ago

Any chance you'd be willing to share a screenshot (with your data blanked out or something) so that I could see what you're seeing?

nhaberl commented 7 years ago

reportviewer - my asp net application

nhaberl commented 7 years ago

the goal now would be that the report gets shrinked so it fits into the viewer in width and adopts the height. the winning feature would be when the report centers automatically afterwards or we have a chnace for setting the alignment.

alanjuden commented 7 years ago

I understand what you're saying now. I don't have any way around this as SSRS controls the output html that I'm rendering.

This link is an article from Microsoft that explains the settings that I have access to pass through the SSRS api to change the settings of the report rendering: https://docs.microsoft.com/en-us/sql/reporting-services/html-device-information-settings

The only thing I could possibly think that may have any impact on the width would be the "Zoom" property but I have not tried that at all. It would be a total guessing game on your part on if that zoom would be consistent across screen sizes or anything.

nhaberl commented 7 years ago

So do you know maybe how the ReportViewer controls handles this ?

nhaberl commented 7 years ago

I had a short chat with the ReportViewer team and they told me that they are doing the scaling / zoom with translate:scale() (as thought :-)) ... so maybe you could add a feature where width and height of the target container is sent with the request and after rendering the report get scaled so it fits into the container.

Upside down it would be great if the target container increases the height if the report is bigger ... same as full width when setting the zoom level)

nhaberl commented 7 years ago

Let me know if you would like to have further information