SSRS:2005,CSS 未应用于第一列
我们的一些报告在 Firefox 中无法正确显示 - 第一列缺少任何 CSS。 经过调查,我发现:
<tr>
<td style="HEIGHT:6.93mm" style="...">1st Column</td>
<td style="...">2nd Column</td>
<td style="...">3rd Column</td>
</tr>
当我删除 style="HEIGHT:6.93mm" 时,它在 Firefox 中正确呈现。
根据 JudyX 的帖子此处2006 年 2 月 13 日星期一晚上 11:54:
报告中第一列的样式无法正确设置。 报表查看器控件要求为所有表行指定“高度”。 不幸的是,它不会将此应用于表行元素,而是应用于该行中的第一个表单元格。 当它将其应用为样式属性时,它与我们在其他地方设置的样式冲突。
有没有人找到解决这个问题的方法?
Some of our reports aren't displaying properly in Firefox - the first column lacks any css. After investigating, I'm finding:
<tr>
<td style="HEIGHT:6.93mm" style="...">1st Column</td>
<td style="...">2nd Column</td>
<td style="...">3rd Column</td>
</tr>
When I remove the style="HEIGHT:6.93mm", it renders properly in Firefox.
Per JudyX's post here on Monday, February 13, 2006 11:54 PM:
The first column in reports cannot be styled correctly. The report viewer control requires a “height” be specified for all table rows. Unfortunately, it applies this not to the table-row element, but to the first table-cell within that row. When it applies that as a style attribute, it conflicts with the style that we set elsewhere.
Has anyone found a solution to this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我可以确认 SSRS 2005 中仍然会发生这种情况。Firefox 并不是唯一不能按照报表设计者的预期呈现此情况的浏览器。 显然,如果一个元素上分配了多个样式属性,则 IE7(可能还有 IE6)会假定最后一个样式属性为“win”。 在这种情况下,标准模式下的 IE8 和 Firefox 假定第一个样式属性为“win”。 我假设所有符合标准的浏览器都会做出与 IE8 和 Firefox 相同的选择,尽管我们的团队尚未对此进行测试。
我还没有找到修复程序方面的解决方案,但我确实有办法防止错误的 HTML 进入浏览器。 OMG Ponies - 感谢您将链接发布到 JudyX 的帖子。 Wodeh 在该帖子的 3/4 处回复了一个很好的解决方案 - 不幸的是,并不完全清楚如何使用发布的代码。
该方法是使用响应过滤器在包含 报表查看器控件。 过滤器可以访问将发送到浏览器的原始 HTML,这提供了直接修改 HTML 的机会,而不必导致新的第一列技巧。 在 Page_Load 方法中,我们使用以下代码设置 Response.Filter 属性:
CorrectSSRSIssuesResponseFilter 类定义如下,主要基于帖子中的 Wodeh 代码。 秘诀在于 Write() 方法,该方法使用正则表达式删除第一个样式属性:
I can confirm that this still happens with SSRS 2005. Firefox is not the only browser that will not render this as intended by the report designer. Apparently IE7 (and probably IE6) assume the last style attribute to "win" if there are multiple style attributes assigned on an element. IE8 in standards mode and Firefox assume the first style attribute to "win" in this situation. I would assume that all standards compliant browsers will make the same choice as IE8 and Firefox, although our team has not tested this.
I haven't found a solution in terms of a hotfix, but I do have a way to prevent the bad HTML from making it to the browser. OMG Ponies - thanks for posting that link to JudyX's post. Wodeh responded with a good solution about 3/4 of the way down that post - unfortunately, it was not entirely clear how to use the code that was posted.
The approach is to use a response filter on the page that contains the ReportViewer Control. The filter has access to the raw HTML that will be sent to the browser, and that provides the opportunity to modify the HTML directly without having to result to the new first column trick. In our Page_Load method, we set the Response.Filter property with the following code:
The CorrectSSRSIssuesResponseFilter class is defined as follows, and is mostly based off of Wodeh's code from the post. The secret sauce is in the Write() method which uses the RegEx to wipe out the first style attribute:
解决方案并不是真正的解决方案;而是解决方案。 这是一个黑客行为。
当该行为出现时,定义新的第一列。 它应该具有以下属性:
The solution isn't really a solution; it's a hack.
When the behavior appears, define a new first column. It should have the following attributes:
这是 CSS 样式问题。 我过去使用 这篇文章:
您基本上必须找到报告服务的 css 文件(默认情况下,位于 C:\Program Files\Microsoft SQL Server\MSSQL .3\Reporting Services\ReportManager\Styles\ReportingServices.css(在报表服务器上),并向其中添加此类规则:
This is a CSS styling issue. I have successfully implemented a fix for this in the past using the info from this post:
You basically have to locate the css file for reporting services (by default, located at C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportManager\Styles\ReportingServices.css on the report server), and add this class rule to it:
在
ReportViewer
控件上尝试AsyncRendering="true"
。通过异步渲染,生成的 HTML 没有两个样式标签 - 它使用 sytle 标签作为高度,所有其他样式都通过
td
元素上的class
属性应用。Try
AsyncRendering="true"
on theReportViewer
control.With async rendering the generated HTML does not have two style tags – it uses a sytle tag for the height and all other styles are applied through a
class
attribute on thetd
element.在我的例子中,一个更简单的解决方法解决了这个问题。 只需在损坏的行下方添加另一行并设置 Visibility:Hidden = True。
祝你好运!
A much more simpler workaround fixed this issue in my case. Just added anoter row below the damaged one and set Visibility:Hidden = True.
Good luck!