开发者

Displaytag table exported header column contains span tags

开发者 https://www.devze.com 2022-12-29 19:36 出处:网络
When I export the content of the display tag table I use the data shows up fine, but the header cells are surrounded by html span tag开发者_JS百科s, which is slightly annoying.

When I export the content of the display tag table I use the data shows up fine, but the header cells are surrounded by html span tag开发者_JS百科s, which is slightly annoying.

I can imagine why Displaytag uses spans around the column header's text, but it shouldn't transpose in the exported data I think.

Here is my displaytag.properties config related to export:

# Export
export.amount = list
export.decorated = true
export.banner=<div id="exportTypes"><span class="label">Export: </span>{0}</div>
export.banner.sepchar=&nbsp;|
export.types=excel csv xml
export.excel=true
export.csv=true
export.xml=false
export.excel.label=xls
export.csv.label=csv
export.xml.label=xml
export.excel.filename=export.xls
export.csv.filename=export.csv
export.xml.filename=export.xml
export.excel.include_header=true
export.csv.include_header=true
export.xml.include_header=true

Here is the displaytag table itself:

<display:table
   class="list sortable"
   defaultsort="1"
   export="true"
   htmlId="contacts"
   id="row" 
   name="contacts" 
   requestURI="">

   <display:setProperty name="export.banner"><div id="exportTypes"><span class="label">Export:</span> {0}</div></display:setProperty>
   <display:setProperty name="export.csv.filename">CSV</display:setProperty>
   <display:setProperty name="export.excel.filename">XLS</display:setProperty>
   <display:setProperty name="basic.msg.empty_list_row">
    <tr class="empty">
     <td colspan="7">Empty</td>
    </tr>
   </display:setProperty>

   <display:column class="lastName" property="lastName" sortProperty="lastName" headerClass="lastName first" sortable="true" titleKey="Lastname" href="contact/view" paramId="contactId" paramProperty="id" />
   <display:column property="firstName" class="firstName" headerClass="firstName" sortable="true" titleKey="FirstName" />
   <display:column class="loginName" headerClass="loginName" sortable="true" titleKey="Username" />
</display:table>

My problem is when I click export on either the CSV or the XLS format the header row in the generated file looks like this:

<span>Last Name</span> <span>First Name</span> <span>Username</span>

I really don't want those span tags in there, any way to work around that?

Thanks


Found the problem, this was due to us using a string from the message.properties containing offending text in the titlekey field. However removing the span tags from the text in the message.properties file turns out to remove the sorting arrow on the columns in the web page... so that's still not perfect of a solution. :(

0

精彩评论

暂无评论...
验证码 换一张
取 消