自定义p:dataTable的导出输出格式 [英] Customize export output format of p:dataTable

查看:124
本文介绍了自定义p:dataTable的导出输出格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Primefaces数据表,其中一列包含三个输出文本和一个带工具提示的命令按钮。该按钮的输出标签显示为

I have a Primefaces dataTable where one column is having three output texts and one command button with tooltip. The button appears with output labels as


这是用于导出标签。这是针对text.org.primefaces.component.commandbutton.CommandButton@3f60d3f9

This is for export label. This is for text.org.primefaces.component.commandbutton.CommandButton@3f60d3f9

我如何不包含/打印该命令按钮?将数据表导出到excel的工具提示?

How can I not include/print this command button with tooltip to export the dataTable to excel?

我无法将命令按钮移至用于业务案例的新列。

I can't move the command button to new column for business case.

推荐答案

在PrimeFaces中,您可以使用exportFunction属性(在文档中)覆盖bij列的导出内容。如果您在文档中阅读了此内容,则很容易找到 https://使用Google的forum.primefaces.org/viewtopic.php?t=50284 。在其中给出了一个示例,该示例说明如何覆盖列的导出值:

In PrimeFaces you can override the exported content of a column bij using the exportFunction attribute (which is in the documentation). If you'd read this in the documentation, you'd easily have found https://forum.primefaces.org/viewtopic.php?t=50284 by using google. In it, an example is given of how to override the 'exported value' of a column:

XHTML:

<p:column exportFunction="#{testView.exportBrand}">
   <f:facet name="header">
       <h:outputText value="Brand" />
  </f:facet>
  <h:outputText value="#{car.brand}" />
</p:column>

Java:

public String exportBrand(UIColumn column) {
    String value = "";
    for(UIComponent child: column.getChildren()) {
        if(child instanceof ValueHolder) {
            value = ComponentUtils.getValueToRender(FacesContext.getCurrentInstance(), child);
        }
    }

    return value + "_TEST";
}

只需扩展此内容,并且在for循环中仅导出要导出的内容。

Just extend this and in the for loop only export things you want to export.

这篇关于自定义p:dataTable的导出输出格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆