转载自:http://youlong05.iteye.com/blog/37726
- 一、简介
- Extreme Table是最功能强大而又容易配置,扩展,自定义的Table 控件。
- 最主要的功能包括排序, 分页, 导出Excel, pdf和汇总
-
- 官方网站:
- http:
- ExtremeTable自带的文档:
- http:
- Luck翻译的ExtremeTable官方文档中文版:
- http:
-
- 二、简单示例
- 1,将extremecomponents.jar丢入WEB-INF/lib
- 2,将SpringSide与ec的相关images丢入/resources/images/table
- 3,将SpringSide的extremecomponents.css丢入/resources/css
- 4,将SpringSide的extremetable.properties丢入classpath,如src-conf/table
- 5,extremecomponents.css:
-
- .eXtremeTable {
- margin: 0;
- padding: 0;
- }
-
- .eXtremeTable select {
- font-family: verdana, arial, helvetica, sans-serif;
- font-size: 12px;
- border: solid 1px #EEE;
- width: 75px;
- }
-
- .eXtremeTable .tableRegion {
- border: 1px solid #AAC2D9;
- padding: 2px;
- font-size: 12px;
- margin-top: 7px;
- }
-
- .eXtremeTable .filter {
- background-color: #F4F4F4;
- }
-
- .eXtremeTable .title {
- color: #1a7cdf;
- vertical-align: middle;
- font-size: 18px;
- font-weight: bold;
-
- }
-
- .eXtremeTable .titleRow {
- background-color: #F4F4F4;
- }
-
- .eXtremeTable .titleRow td {
- border-bottom: 1px solid #308dbb;
- padding-top: 2px;
- padding-bottom: 2px;
- vertical-align: middle;
- }
-
- .eXtremeTable .titleRow span {
- color: #444444;
- font-weight: bold;
- font-size: 12px;
- }
-
- .eXtremeTable .filter input {
- font-size: 12px;
- width: 100%;
- }
-
- .eXtremeTable .filter select {
- font-size: 9px;
- border: solid 1px #EEE;
- width: 100%;
- }
-
- .eXtremeTable .tableHeader {
- background-color: #308dbb;
- color: white;
- font-size: 12px;
- font-weight: bold;
- text-align: left;
- padding-right: 3px;
- padding-left: 3px;
- padding-top: 4px;
- padding-bottom: 4px;
- margin: 0px;
- border-right: 1px solid white;
- background-image: url( "../images/tableTopbg.gif" );
- }
-
- .eXtremeTable .tableHeaderSort {
- background-color: #3a95c2;
- color: white;
- font-size: 12px;
- font-weight: bold;
- text-align: left;
- padding-right: 3px;
- padding-left: 3px;
- padding-top: 4px;
- padding-bottom: 4px;
- white-space: nowrap;
- border-right: 1px solid white;
- background-image: url( "../images/tableTopbg.gif" );
- }
-
- .eXtremeTable .odd a, .even a {
- color: Black;
- font-size: 12px;
- }
-
- .eXtremeTable .odd td, .eXtremeTable .even td {
- vertical-align: middle;
- font-size: 12px;
-
- padding-right: 3px;
- padding-left: 3px;
- padding-top: 4px;
- padding-bottom: 4px;
- border-bottom: 1px solid #CADAE8;
- border-right: 1px solid #DAE6EF;
- }
-
- .eXtremeTable .odd {
- background-color: #FFFFFF;
- }
-
- .eXtremeTable .even {
- background-color: #F8F8F8;
- }
-
- .eXtremeTable .highlight td {
- color: black;
- font-size: 12px;
- vertical-align: middle;
- background-color: #fdecae;
-
- padding-right: 3px;
- padding-left: 3px;
- padding-top: 4px;
- padding-bottom: 4px;
- border-bottom: 1px solid #CADAE8;
- border-right: 1px solid #DAE6EF;
- }
-
- .eXtremeTable .highlight a, .highlight a {
- color: black;
- font-size: 12px;
- }
-
- .eXtremeTable .toolbar {
- background-color: #FFFFFF;
- font-size: 12px;
- border-right: 1px solid silver;
- border-left: 1px solid silver;
- border-top: 1px solid silver;
- border-bottom: 1px solid silver;
- }
-
- .eXtremeTable .toolbar td {
- color: #444444;
- padding: 0px 3px 0px 3px;
- text-align: center;
- }
-
- .eXtremeTable .separator {
- width: 7px;
- }
-
- .eXtremeTable .statusBar {
- background-color: #FFFFFF;
- font-size: 12px;
- }
-
- .eXtremeTable .filterButtons {
- background-color: #F4F4F4;
- text-align: right;
- }
-
- .eXtremeTable .title span {
- margin-left: 7px;
- }
-
- .eXtremeTable .formButtons {
- display: block;
- margin-top: 10px;
- margin-left: 5px;
- }
-
- .eXtremeTable .formButton {
- cursor: pointer;
- font-size: 12px;
- font-weight: bold;
- background-color: #308dbb;
- color: white;
- margin-top: 5px;
- border: outset 1px #333;
- vertical-align: middle;
- }
-
- .eXtremeTable .calcRow {
- background-color: #FFFFFF;
- }
-
- .eXtremeTable .calcRow td {
- background-color: #FFFFFF;
- border-top: 1px solid #cccccc;
- border-right: 1px solid #cccccc;
- }
-
- .eXtremeTable .calcTitle {
- font-weight: bold;
- font-size: 12px;
- }
-
- .eXtremeTable .calcResult {
- font-size: 12px;
- }
- 6,extremetable.properties:
- table.filterable=false
- table.imagePath=/resources/images/table
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public class ExtremeTablePage {
-
- static public Limit getLimit(HttpServletRequest request) {
- return getLimit(request, Constants.DEFAULT_PAGE_SIZE);
- }
-
-
-
-
-
-
-
-
- static public Limit getLimit(HttpServletRequest request, int defautPageSize) {
- Context context = new HttpServletRequestContext(request);
- LimitFactory limitFactory = new TableLimitFactory(context);
- TableLimit limit = new TableLimit(limitFactory);
- limit.setRowAttributes(1000000000, defautPageSize);
- return limit;
- }
-
-
-
-
- static public Map getSort(Limit limit) {
- Map sortMap = new HashMap();
- if (limit != null) {
- Sort sort = limit.getSort();
- if (sort != null && sort.isSorted()) {
- sortMap.put(sort.getProperty(), sort.getSortOrder());
- }
- }
- return sortMap;
- }
- }
- 10,commonManager.findBy(args)用到SpringSide的BaseHibernateDao并有扩展:
- public Page findBy(Class clazz, Map filterMap, Map orderMap, int pageNo, int
- pageSize, CriteriaSetup criteriaSetup) {
-
- Criteria criteria = null;
-
- if(clazz == null) {
-
- criteria = getSession().createCriteria(getEntityClass());
-
- } else {
-
- criteria = getSession().createCriteria(clazz);
-
- }
-
- if (!CollectionUtils.isEmpty(filterMap)) {
- try {
- criteriaSetup.setup(criteria, filterMap);
- } catch (Exception e) {
- }
- }
-
- if (!CollectionUtils.isEmpty(orderMap))
- sortCriteria(criteria, orderMap, null);
-
- criteria.setResultTransformer(CriteriaSpecification.ROOT_ENTITY);
-
- return pagedQuery(criteria, pageNo, pageSize);
- }
- 11,listBlog.jsp:
- <%@ taglib prefix="ec" uri="http:
- <link href="/resources/css/extremecomponents.css" rel="stylesheet"
- type="text/css">
- <ec:table
- var="blog"
- items="blogList"
- action="/blog.do"
- retrieveRowsCallback="limit"
- sortRowsCallback="limit"
- rowsDisplayed="10">
- <ec:row>
-
- <ec:column property="name" title="博客名称"/>
-
- <ec:column property="user.name" title="博客作者" alias="userName"/>
-
- <ec:column property="description" title="描述"/>
-
- <ec:column property="edit" title="操作" sortable="false" viewsAllowed="html">
-
- <a href="blog.do?method=edit&id=${blog.id}">
-
- 编辑
-
- </a>
-
- </ec:column>
- </ec:row>
- </ec:table>
- 12,web.xml
- <context-param>
- <param-name>extremecomponentsPreferencesLocation</param-name>
- <param-value>/table/extremetable.properties</param-value>
- </context-param>