- dojo.provide("navigationGrid");
- dojo.require("dojox.grid.DataGrid");
- dojo.require('dijit.Toolbar');
- dojo.require("dijit.form.Button");
- dojo.require("dijit.ToolbarSeparator");
- dojo.declare("navigationGrid",dojox.grid.DataGrid,{
- //当前页码号
- currentPage:1,
- totalPage:1,
- maxPageNum:5,0); background-color:inherit">//页码按钮
- _pageBtns:null,
- //导航条对象
- _naviBar: _firstBtn: _prvIoUsBtn: _nextBtn: _lastBtn: _pageLoaded:false,108); list-style:decimal-leading-zero outside; color:inherit; line-height:24px; margin:0px!important; padding:0px 3px 0px 10px!important">
- postCreate:function(){
- this.inherited(arguments);
- this._pageBtns=[];
- this._naviBar=newdijit.Toolbar(
- {
- style:"width:100%;text-align:right"
- });
- this._firstBtn=newdijit.form.Button({
- label:"首页"
- ,disabled:true
- ,iconClass:"navi-first",108); list-style:decimal-leading-zero outside; color:inherit; line-height:24px; margin:0px!important; padding:0px 3px 0px 10px!important"> onClick:dojo.hitch(this,"_locate",'first')
- this._prvIoUsBtn= label:"上一页"
- "navi-prevIoUs",'pre')
- this._nextBtn= label:"下一页"
- "rtl"
- "navi-next",248)"> onClick:dojo.hitch('next')
- });
- this._lastBtn=newdijit.form.Button({
- label:"末页"
- true
- "rtl"
- "navi-last",'last')
- this._naviBar.addChild(this._firstBtn);
- newdijit.ToolbarSeparator());
- this._prvIoUsBtn);
- this._nextBtn);
- this._lastBtn);
- this._naviBar.placeAt(this.domNode,"after");
- //this._naviBar.startup();
- },248)"> _locate:function(s){
- switch(s){
- case'first':
- this._navigate(1);
- break;
- case'pre':
- this._navigate(this.currentPage-1);
- break;
- case'next':
- this.currentPage+1);
- case'last':
- this.totalPage);
- default:
- }
- },248)"> _updateBtnStatus:function(pageNo){
- /*
- *更新按钮的状态和样式
- */
- if(pageNo>1){
- this._firstBtn.set('disabled',false);
- this._prvIoUsBtn.set('disabled',153); font-weight:bold; background-color:inherit">false);
- }else{
- true);
- true);
- if(pageNo<this.totalPage){
- this._nextBtn.set('disabled',153); font-weight:bold; background-color:inherit">this._lastBtn.set('disabled',248)"> }else{
- }
- //清除当前页的样式
- /*varcurrentPageIdx=(this.maxPageNum?this.currentPage%this.maxPageNum:this.maxPageNum)-1;
- varpageNoIdx=(this.maxPageNum?pageNo%this.maxPageNum:this.maxPageNum)-1;
- pageNoIdx=pageNoIdx<0?this.maxPageNum-1:pageNoIdx;
- if(this._pageBtns[currentPageIdx]){
- this._pageBtns[currentPageIdx].set('class','');
- }
- if(this._pageBtns[pageNoIdx]){
- this._pageBtns[pageNoIdx].set('class','navi-currentPage');
- }*/
- /**
- *重新载入当前页面
- */
- reload:function(){
- varrow=this._pageToRow(this._fetch(row,0); background-color:inherit">*指向导航页面
- _navigate:if(this.currentPage==pageNo){return}
- if(pageNo<1||pageNo>this.totalPage){return}
- this._updateBtnStatus(pageNo);
- this._pageToRow(pageNo-1);
- this.currentPage=pageNo;
- //this._clearData();
- _onFetchComplete:function(items,req){
- if(!this.scroller){return;}
- if(items&&items.length>0){
- //console.log(items);
- /*for(vari=0;i<this.rowsPerPage;i++){
- if(items.length>i){
- this._addItem(items[i],i,true);
- }else{
- this._addItem({},0); background-color:inherit">}
- }*/
- dojo.forEach(items,function(item,idx){
- this._addItem(item,idx,153); font-weight:bold; background-color:inherit">this);
- this._autoHeight){
- this._skipRowRenormalize=true;
- this.updateRowCount(items.length);
- this.updateRows(0,items.length);
- this._autoHeight){
- false;
- if(req.isRender){
- this.setScrollTop(0);
- this.postrender();
- elsethis._lastScrollTop){
- this.setScrollTop(this._lastScrollTop);
- deletethis._lastScrollTop;
- this._isLoaded){
- this._isLoading=false;
- this._isLoaded=true;
- this._pending_requests[req.start]=//重写父类的方法,初始化导航数字按钮
- _onFetchBegin:function(size,req){
- this._updateButtons(size);
- if(!size){
- this.views.render();
- this._resize();
- this.showMessage(this.noDataMessage);
- this.focus.initFocusView();
- return;
- this.showMessage();
- this.rowCount!=this.rowsPerPage){
- this.scroller.init(this.rowsPerPage,153); font-weight:bold; background-color:inherit">this.rowsPerPage);
- this.rowCount=this.rowsPerPage;
- this._setAutoHeightAttr(this.autoHeight,153); font-weight:bold; background-color:inherit">this.prerender();
- this.updateRowCount(this.rowsPerPage);
- _clearData:this.inherited(arguments);
- this.currentPage=1;
- this.totalPage=1;
- dojo.forEach(this._pageBtns,153); font-weight:bold; background-color:inherit">function(btn){
- btn.destroy();
- })
- this._firstBtn){
- this._prvIoUsBtn){
- this._nextBtn){
- this._lastBtn){
- this._pageLoaded= _updateButtons:function(size){
- //TODO先销毁按钮组
- this._pageBtns){
- dojo.forEach(function(element){
- element.destroy();
- })
- this._pageBtns=[];
- //初始化数字按钮条
- vartotalPage=(this.rowsPerPage?Math.ceil(size/this.rowsPerPage):size);
- varisShow=varisFirstRightDot=varisFirstLefttDot=varbeginIndex=4;
- for(vari=1;i<=totalPage;i++){
- if(i==1||i==2||i==totalPage||i==totalPage-1
- ||i==this.currentPage-1||i==this.currentPage-2
- ||i==this.currentPage+1||i==this.currentPage+2){
- isShow=this.currentPage==i){
- varnumBtn= label:i,248)"> baseClass:"",108); list-style:decimal-leading-zero outside; color:inherit; line-height:24px; margin:0px!important; padding:0px 3px 0px 10px!important"> tooltip:"第"+i+"页",248)"> style:{border:"1pxsolid#A8AAE2",margin:"1px"},108); list-style:decimal-leading-zero outside; color:inherit; line-height:24px; margin:0px!important; padding:0px 3px 0px 10px!important"> cssStateNodes:{"titleNode":"navi"},"_navigate",i)
- this._pageBtns.push(numBtn);
- numBtn.set('disabled',248)"> dojo.addClass(numBtn.domNode,'navi-selected');
- this._naviBar.addChild(numBtn,beginIndex);
- beginIndex++;
- if(isShow==true){
- label:i,108); list-style:decimal-leading-zero outside; color:inherit; line-height:24px; margin:0px!important; padding:0px 3px 0px 10px!important"> baseClass:"",248)"> tooltip:"第"+i+"页",108); list-style:decimal-leading-zero outside; color:inherit; line-height:24px; margin:0px!important; padding:0px 3px 0px 10px!important"> style:{border:"1pxsolid#A8AAE2",248)"> cssStateNodes:{"titleNode":"navi"},i)
- this._pageBtns.push(numBtn);
- beginIndex++;
- if(isFirstLefttDot==false&&i==this.currentPage-3){
- label:'...',108); list-style:decimal-leading-zero outside; color:inherit; line-height:24px; margin:0px!important; padding:0px 3px 0px 10px!important"> disabled: isFirstLefttDot=if(isFirstRightDot==false&&i>this.currentPage){
- label:'...',248)"> disabled: isFirstRightDot=/*varnumBtn=newdijit.form.Button({
- label:i+1,0); background-color:inherit">baseClass:"",0); background-color:inherit">tooltip:"第"+(i+1)+"页",0); background-color:inherit">style:{border:"1pxsolid#A8AAE2",margin:"1px"},0); background-color:inherit">cssStateNodes:{"titleNode":"navi"},0); background-color:inherit">onClick:dojo.hitch(this,"_navigate",i+1)
- });
- this._pageBtns.push(numBtn);
- this._naviBar.addChild(numBtn,i+4);
- this._naviBar.addChild(newdijit.form.Button({label:"...",baseClass:"",disabled:true}),btnsNum+3);
- varlasBtn=newdijit.form.Button({
- label:totalPage,0); background-color:inherit">tooltip:"第"+(totalPage)+"页",totalPage)
- })
- this._pageBtns.push(lasBtn);
- this._naviBar.addChild(lasBtn,btnsNum+4);
- this.totalPage=totalPage;
- //设置按钮的状态
- this._updateBtnStatus(this.currentPage);
- //this._pageLoaded=true;
- });