2006年6月16日

          點擊http://www.aygfsteel.com/Files/nicetomeetu/extremecomponents-1.0.1.zip下載,另請自行制作一張名為pageJump.gif的圖片,放置在圖片的目錄下
          posted @ 2006-06-20 08:49 coolliu 閱讀(215) | 評論 (0)編輯 收藏
           

          ExtremeTable在大量記錄造成大數分頁時沒有很好的解決頁面的快速跳轉,這是較遺憾的一個缺陷。最近因項目用到ExtremeTable,所以我就簡單的添加了這個功能,當因為時間關系,并沒有深入的完善。這里我先將我的代碼貼出來,希望后續有人能繼續完善。

          1.org.extremecomponents.table.view.html.ToolbarBuilder? 中加入如下方法。

          ??? public void pageJumpDroplist(){
          ??????? Integer total = new Integer(model.getLimit().getTotalRows());
          ???????? Integer from = new Integer(model.getLimit().getRowStart() + 1);
          ???????? Integer to = new Integer(model.getLimit().getRowEnd());
          ???????? Integer current = new Integer(model.getLimit().getCurrentRowsDisplayed());
          ???????? Integer totalPage = (Integer)total/current;
          ???????? if(total%current!=0)
          ??????????????? totalPage=totalPage+1;
          ??????? int currentPage = model.getLimit().getPage();

          ??????? html.select().name(model.getTableHandler().prefixWithTableId() + TableConstants.DROWDOWNLIST_PAGE);

          ??????? StringBuffer onchange = new StringBuffer();
          ??????? onchange.append(new TableActions(model).getPageJumpAction());
          ??????? html.onchange(onchange.toString());

          ??????? html.close();

          ??????? html.newline();
          ??????? html.tabs(4);

          ??????? for(int i=1;i<=totalPage;i++){
          ??????????? html.option().value("" + i);
          ??????????? if (currentPage == i) {
          ??????????????? html.selected();
          ??????????? }???????????
          ??????????? html.close();
          ??????????? html.append(String.valueOf(i));
          ??????????? html.optionEnd();
          ??????? }
          ??? }


          2.org.extremecomponents.table.view.html.TableActions 中加入

          ??? public String getPageJumpAction(){
          ??????? StringBuffer action = new StringBuffer("javascript:");
          ??????? action.append(getClearedExportTableIdParameters());
          ??????? action.append(getPageJumpFormParameter(TableConstants.PAGE));
          ??????? action.append(getOnInvokeAction());
          ??????? return action.toString();
          ??? }

          ??? protected String getPageJumpFormParameter(String name) {
          ??????? StringBuffer result = new StringBuffer();

          ??????? String form = BuilderUtils.getForm(model);
          ??????? String selectedOption = "this.options[this.selectedIndex].value";
          ??????? result.append("document.forms.").append(form).append(".");
          ??????? result.append(model.getTableHandler().prefixWithTableId()).append(name);
          ??????? result.append(".value=").append(selectedOption).append(";");

          ??????? return result.toString();
          ??? }

          3.org.extremecomponents.table.view.DefaultToolbar 中你想要放置頁面跳轉下拉框的地方加入如下代碼

          ??????????? html.td(4).close();
          ??????????? toolbarBuilder.pageJumpDroplist();
          ??????????? html.tdEnd();


          我將我加的地方貼整個方法貼出來(紅色是有修改的地方)
          ??? protected void columnRight(HtmlBuilder html, TableModel model) {
          ??????? boolean showPagination = BuilderUtils.showPagination(model);
          ??????? boolean showExports = BuilderUtils.showExports(model);

          ??????? ToolbarBuilder toolbarBuilder = new ToolbarBuilder(html, model);

          ??????? html.td(2).align("right").close();

          ??????? html.table(2).border("0").cellPadding("0").cellSpacing("1").styleClass(BuilderConstants.TOOLBAR_CSS).close();

          ??????? html.tr(3).close();

          ??????? if (showPagination) {

          ??????????? html.td(4).close();
          ??????????? toolbarBuilder.firstPageItemAsImage();
          ??????????? html.tdEnd();

          ??????????? html.td(4).close();
          ??????????? toolbarBuilder.prevPageItemAsImage();
          ??????????? html.tdEnd();

          ??????????? html.td(4).close();
          ??????????? toolbarBuilder.nextPageItemAsImage();
          ??????????? html.tdEnd();

          ??????????? html.td(4).close();
          ??????????? toolbarBuilder.lastPageItemAsImage();
          ??????????? html.tdEnd();

          ??????????? html.td(4).close();
          ??????????? toolbarBuilder.separator();
          ??????????? html.tdEnd();


          ??????????? html.td(4).close();
          ??????????? toolbarBuilder.pageJumpDroplist();
          ??????????? html.tdEnd();

          ??????????? html.td(4).close();
          ??????????? toolbarBuilder.separator();
          ??????????? html.tdEnd();


          ??????????? html.td(4).style("width:20px").close();
          ??????????? html.newline();
          ??????????? html.tabs(4);
          ??????????? toolbarBuilder.rowsDisplayedDroplist();
          ??????????? html.img();
          ??????????? html.src(BuilderUtils.getImage(model, BuilderConstants.TOOLBAR_ROWS_DISPLAYED_IMAGE));
          ??????????? html.style("border:0");
          ??????????? html.alt("Rows Displayed");
          ??????????? html.xclose();
          ??????????? html.tdEnd();

          ??????????? if (showExports) {
          ??????????????? html.td(4).close();
          ??????????????? toolbarBuilder.separator();
          ??????????????? html.tdEnd();
          ??????????? }
          ??????? }

          ??????? if (showExports) {
          ??????????? Iterator iterator = model.getExportHandler().getExports().iterator();
          ??????????? for (Iterator iter = iterator; iter.hasNext();) {
          ??????????????? html.td(4).close();
          ??????????????? Export export = (Export) iter.next();
          ??????????????? toolbarBuilder.exportItemAsImage(export);
          ??????????????? html.tdEnd();
          ??????????? }
          ??????? }

          ??????? html.trEnd(3);

          ??????? html.tableEnd(2);
          ??????? html.newline();
          ??????? html.tabs(2);

          ??????? html.tdEnd();
          ??? }


          4.org.extremecomponents.table.core.TableConstants中加入一行


          public final static String DROWDOWNLIST_PAGE= "dp";



          5.編譯打包,ok,搞定了。下周我會把我的jar傳上來。


          就這樣,不是很難,ExtremeTable是個不錯的東東,希望大家一起來完善。

          posted @ 2006-06-16 17:43 coolliu 閱讀(1909) | 評論 (7)編輯 收藏
           
          主站蜘蛛池模板: 广河县| 福安市| 寻乌县| 八宿县| 全州县| 英超| 龙泉市| 大方县| 中卫市| 诸暨市| 邹城市| 色达县| 丽江市| 澎湖县| 佛学| 南投市| 噶尔县| 同仁县| 察雅县| 保康县| 嵊州市| 南投市| 仁怀市| 长泰县| 兰坪| 淮滨县| 绥棱县| 惠水县| 郴州市| 寿阳县| 富宁县| 土默特左旗| 奎屯市| 涡阳县| 青海省| 河东区| 辽阳市| 枝江市| 甘洛县| 红河县| 西昌市|