转自Qhttp://mhbjava.javaeye.com/blog/26591
1.
<ec:table
items="presidents"
var="pres"
imagePath="${pageContext.request.contextPath}/images/*.gif"
action="${pageContext.request.contextPath}/presidents.run"
filterable="false"
sortable="false" >
...
</ec:table>
<ec:table>里的属性还?
a. rowsDisplayed,rowsDisplayed也可以在extremecomponents.properties文g中设?br />
b. showPagination ,如果你想在一中昄所有行Q只需要设|showPagination为false?br />
c. TableTag兌了很多样式属性:
<ec:table cellspacing="0" cellpadding="0" border="0" width="80%" styleClass="" />
所有这些都是可选的?/p>
2.
使用highlightRow属性可以设|行的高亮显C,它的gؓtrue或falseQ默认gؓfalse?/p>
<ec:table items="presidents" var="pres" action="${pageContext.request.contextPath}/presidents.run" >
<ec:row highlightRow="true">
<ec:column property="name"/>
<ec:column property="term"/>
</ec:row>
</ec:table>
讄highlightRow属性后Q它插入设|行csscȝjavascript脚本Q默认的css cMؓhighlight。你可以使用highlightClass来用定制的csscR?/p>
3.
Z便于你对于行数据q行动态交互处理,提供了onclick、onmouseover?onmouseout属性?/p>
<ec:row onclick="" onmouseover="" onmouseout="" />
4.
RowTag兌了很多样式属性:
<ec:row styleClass="" highlightClass="" />
5.
提供可选取值方法的主要原因是你能够对其他cd的html标签提供动作支持Q例如显C?一q图片或者通过定义href使该列成为到其它늚一个链接?/p>
<ec:table items="presidents" var="pres" action="${pageContext.request.contextPath}/presidents.run" >
<ec:row>
<ec:column property="lastName">
<a href=">
</ec:column>
</ec:row>
</ec:table>
6?br />
<ec:column property="time" title="旉" parse="yyyy-MM-dd" format="yyyyqMM月dd? cell="date"/>
7?br />
TableTag
中有filterable和sortable属性,ColumnTag中也有相同的属性?
列的filterable和sortable属性将覆盖表的filterable和sortable属性设|。当你需要除了对表中的一、两列之外的
所有列q行qo和排序时Q十分便利?/p>
<ec:table items="presidents" action="${pageContext.request.contextPath}/presidents.run" >
<ec:row>
<ec:column property="firstName" filterable="false"/>
<ec:column property="lastName" sortable="false"/>
</ec:row>
</ec:table>
8。视N题:
viewsAllowed 属性制定类允许使用的视图。视囑括:html、pdf、xls、csvQ以及Q何定制的视图? 如果你指定一个或几个视图Q那么列仅能使用q些指定的视图。例如:你指定viewsAllowed="pdf"Q这意味着 q列只允许PDF导出Q而不能进行其他格式的导出或html视图?/p>
<ec:table items="presidents" action="${pageContext.request.contextPath}/presidents.run" >
<ec:row>
<ec:column property="firstName"/>
<ec:column property="lastName" viewsAllowed="pdf"/>
</ec:row
</ec:table>
viewsDenied
属性制定类不允怋用的视图。视囑括:html、pdf、xls、csvQ以及Q何定制的视图?
如果你指定一个或几个视图Q那么列仅这些指定的视图不能被用。例如:你指定viewsDenied="html"Q这意味着
q列不允怋用html试图Q但能进行Q何Ş式的导出?/p>
<ec:table items="presidents" action="${pageContext.request.contextPath}/presidents.run" >
<ec:row>
<ec:column property="firstName"/>
<ec:column property="lastName" viewsDenied="html"/>
</ec:row>
</ec:table>
9。ParameterTag
eXtremeTable 能够指定是否处理所有的参数。默认ؓ处理所有的参数Q这意味着当你q行 qo、排序、分|Q所有的参数都被eXtremeTable保存q传到JSP中。通常q是你需要的功能Q? 然而,有时候你需要只允许一些特定的参数保存到eXtremeTable中。我喜欢把它看作锁定extremeTableQ? 可以通过讄表的autoIncludeParameters属性gؓfalse来到辄的:
<ec:table
items="presidents"
action="${pageContext.request.contextPath}/presidents.run"
autoIncludeParameters=”false” >
...
</ec:table>
甚至当表被锁定时Q你仍然可以通过单地使用parameter标签来包含一些你想用的参数。下?包含了foo参数Q?/p>
<ec:table
items="presidents"
action="${pageContext.request.contextPath}/presidents.run"
autoIncludeParameters=”false” >
<ec:parameter name=”foo” value=”${param.foo}”/>
...
</ec:table>
现在所有的eXtremeTable参数都被锁定。但qo、排序和页Ӟfoo参数仍将被传递?/p>
10. .propeties取代
Z替代编码eXtremeTable使用的默认属性|我在属性文件中配置所有用到的属性?如果你需要覆盖Q何默认的讄Q你可以创徏自己的extremecomponents.properties文g q设|你x变的倹{?/p>
Z讄属性文Ӟ你应该如下例所C在/WEB-INF/web.xml文g中声明一个context-paramQƈ 指定你的属性文件的路径Q?/p>
<context-param>
<param-name>extremecomponentsPreferencesLocation</param-name>
<param-value>/org/extremesite/resource/extremecomponents.properties</param-value></context-param>
你可以认为属性文件ؓ你提供了一个对所有的eXtremeTables声明全局讄的一个方法?创徏属性文件的最大好处就是避免在标签中复制、粘贴相同的属性。典型的extremecomponents.properties文g如下所C:
table.imagePath=/extremesite/images/*.gif
table.rowsDisplayed=12
column.parse.date=yyyy-MM-dd
column.format.date=MM/dd/yyyy
column.format.currency=$###,###,##0.00
在属性文件定义的TableTag使用最多的两个属性是QimagePath和rowsDisplayed。如果你不在属性文件中声明 q些属性,你需要在每个eXtremeTable中添加他们。典型的表如下所C:
<ec:table
items="presidents"
action="${pageContext.request.contextPath}/presidents.run"
imagePath="${pageContext.request.contextPath}/images/*.gif"
rowsDisplayed="12" title="Presidents" > ...</ec:table>
如果在属性文件声明imagePath和rowsDisplayedQ则表如下所C:
<ec:table
items="presidents"
action="${pageContext.request.contextPath}/presidents.run"
title="Presidents" > ...</ec:table>
正如你所见,属性文仉免了重复~码?/p>
在属性文件定义的ColumnTag使用最多的两个属性是Qparse和format。如果你不在属性文件中声明 q些属性,你需要在每个eXtremeTable中添加他们。典型的列用日期cell如下所C:
<ec:column property="dateOfBirth" cell=”date” parse=”yyyy-MM-dd” format=”MM/dd/yyyy”/>
如果在属性文件声明parse和formatQ则列如下所C:
<ec:column property="dateOfBirth" cell=”date”/>
当然你仍然可以定义parse和format属性来覆盖全局讄Q但是大多数工程对于日期使用一致的parse 和format。需要注意属性文件中parse.date和format.date的声明语法?/p>
下例Z用货币cell的典型列Q?/p>
<ec:column property="salary" cell=”currency” format=”$###,###,##0.00”/>
如果在属性文件声明formatQ则列如下所C:
<ec:column property="salary" cell=”currency”/>
另外Q你可以声明一个定制的formatq在列中通过使用列的basis来用它Q我把这惌为named属性。因此如果你?extremecomponents.properties文g如下所C:
table.format.myCustomDate=yy-MM-dd
那么列可以如下用定制的formatQ?/p>
<ec:column property="dateOfBirth" cell="date" format=”myCustomDate”>
11。ExportTag
eXtremeTable h导出不同格式文g的功能,导出的数据ؓqo和排序后的所有结果集Q? 分页不会影响q回的结果集。换句话_如果表数据分多页昄Q那么所有页的数据都被导出?导出的格式ؓMicrosoft Excel (OpenOffice Calc)、PDF和CSV?/p>
使用ExportXlsTag导出Microsoft Excel (OpenOffice Calc)Q?/p>
<ec:table items="presidents" action="${pageContext.request.contextPath}/presidents.run" />
<ec:exportXls fileName="presidents.xls" tooltip="Export Excel"/>
...
</ec:table>
使用ExportPdfTag导出PDF。所有要做的是指定fileName属性和一些样式属性:
<ec:table items="presidents" action="${pageContext.request.contextPath}/presidents.run" />
<ec:exportPdf
fileName="presidents.pdf" tooltip="Export PDF"
headerColor="blue" headerBackgroundColor="red"
headerTitle="Presidents"/> ...
</ec:table>
使用ExportCsvTag导出CSV。当使用CSV导出是默认的分隔Wؓ‘,’(comma)。你可以使用 delimiter属性来指定为其他的W号。下面ؓ指定‘|’QpipeQؓCSV分隔W的CZQ?/p>
<ec:table items="presidents" action="${pageContext.request.contextPath}/presidents.run" />
<ec:exportCsv fileName="presidents.txt" tooltip="Export CSV" delimiter="|"/>
...
</ec:table>