JRXML - 在表格中显示复选框
我无法在 jrxml 的表格中显示复选框。
这是我的代码示例:
<detail>
<band height="45" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement style="MyCustomStyle" stretchType="RelativeToTallestObject" x="650" y="0" width="80" height="35"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Boolean"><![CDATA[$F{myBooleanVariable}]]>
</textFieldExpression>
</textField>
</band>
</detail>
该列仅显示 true 或 false。我认为在 textFieldExpression 元素中指定 class="java.lang.Boolean"
会将值转换为复选框,但显然,我需要不仅如此。
知道我做错了什么吗?
I can't manage to display a checkbox in a table in jrxml.
Here is a sample of my code:
<detail>
<band height="45" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement style="MyCustomStyle" stretchType="RelativeToTallestObject" x="650" y="0" width="80" height="35"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Boolean"><![CDATA[$F{myBooleanVariable}]]>
</textFieldExpression>
</textField>
</band>
</detail>
The column just displays true or false. I supposed that specifying class="java.lang.Boolean"
in the textFieldExpression element would convert the value to a checkbox but apparently, I need more than that.
Any idea of what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
很简单,在标签上执行此操作 ->imageExpression<-
checkboxFisicoOK:是图像路径的参数。
Simple, do this, on the tag ->imageExpression<-
checkboxFisicoOK: is a parameter of the image path.
我刚刚在您已经制作的解决方案中添加了一些 unicode:
u2713
转换为刻度线,u2717
转换为十字请记住确保您在顶部的语句进行编码您的 xml 页面设置为 UTF8:
I just added some unicode to the solution you already made:
u2713
translates to a tick mark andu2717
to a crossRemember to make sure you're encoding statement at the top of your xml page is set to UTF8:
jasper HTML报告中的复选框可以如下
注意:必须使用支持unicode的字体
在PDF中不能使用以上代码。我们必须使用字体扩展或按如下方式绘制线条
Checkbox in the the jasper HTML report can be as follows
Note: Have to use the font which supports the unicode
In PDF above code cannot be used. Either we have to use font extension or by drawing lines as follows
好吧,显然不可能在使用该语言的表格中添加复选框!
所以现在我只是显示是/否:
这是我能找到的最好的!
Al right so apparently it's not possible to add a checkbox in a table with that language !
So now I just display YES/NO:
That's the best I could find !
对于 PDF,这对我有用,明确将字体设置为支持 unicode 的字体:
For PDF this worked for me, explicitly setting the font to one that supports unicode:
对 Olezt 答案的补充,“DejaVu Sans”字体或“Segoe UI Symbol”适用于勾选的复选框,包括通过导出为 pdf
Jasper Studio
要使其适用于 JaserReport Server,需要将字体添加到 Jasper Studio 和 Jasper Server。
参考:https://community.jaspersoft.com/jasperreports-library/issues/13056< /a>
参考:https://community.jaspersoft.com/wiki/custom-font-font-扩展#Publish_the_Font_to_the_Server
Supplement to Olezt's answer, "DejaVu Sans" font, or "Segoe UI Symbol" works for ticked checkbox, including export to pdf through
Jasper Studio
To make it works for JaserReport Server, need to Add the font to both Jasper Studio and Jasper Server.
Ref: https://community.jaspersoft.com/jasperreports-library/issues/13056
Ref: https://community.jaspersoft.com/wiki/custom-font-font-extension#Publish_the_Font_to_the_Server