BasicGrid.js
上传用户:q2283699q
上传日期:2022-05-17
资源大小:10704k
文件大小:6k
- AW.Formats.XMLString=AW.System.Format.subclass();AW.Formats.XMLString.create=function(){var lng=this.prototype;var pwm=this.superclass.prototype;lng.init=function(){pwm.init.call(this);};lng.dataToText=function(rbq){return(kdf(rbq));};lng.dataToValue=function(rbq){return(this.dataToText(rbq).toLowerCase());};lng.comparator=czsb;};function hjr(qmhb,nmrb,plf,sxn,nvl,tjp,llz){var ycn=new AW.UI.SUBasicGrid(qmhb,nmrb,plf);if(ycn!=undefined){if(llz!=true){ycn.m_XMLTable=new AW.XML.GridTable(nvl);ycn.setCellModel(ycn.m_XMLTable);}ycn.onRowDoubleClicked=tjp;ycn.refresh();if((typeof(sxn)!="undefined")&&(sxn!="")){ycn.setTimeout(function(){this.Update(sxn,true);},0);}}return(ycn);}function kzx(ycn){var element=document.getElementById(ycn.getId());element.style.backgroundPosition="50%";element.style.backgroundRepeat="no-repeat";element.style.backgroundImage="url("+yxlb+"BusyGrid.gif)";}AW.XML.GridTable=AW.XML.Table.subclass();AW.XML.GridTable.create=function(){var lng=this.prototype;var pwm=this.superclass.prototype;lng.init=function(nvl){pwm.init.call(this);if((typeof(nvl)!="undefined")&&(nvl!=""))this.setTable("//"+nvl);};lng.responseDef=lng.response;lng.response=function(lhl){var fbs=true;if((this.$owner)&&(typeof(this.$owner.PreUpdate)!="undefined"))fbs=this.$owner.PreUpdate();if(fbs){this.responseDef(lhl);if(this.$owner.m_bFilterMode)this.$owner.FilterGrid(this.$owner.m_sSearchVal,this.$owner.m_nColPos,true,this.$owner.m_bAllowEmpty);if((this.$owner)&&(typeof(this.$owner.PostUpdate)!="undefined"))this.$owner.PostUpdate();}};lng.requestDef=lng.request;lng.request=function(mty){if((this.$owner)&&(mty))kzx(this.$owner);this.requestDef();};lng.setData=function(wtr,ysjb,nffb){var vffb=this.getNode(ysjb,nffb);wtr=encodeURIComponent(wtr);if(AW.ie)vffb.text=wtr;else vffb.textContent=wtr;};lng.setURLDef=lng.setURL;lng.setURL=function(hzw){var jrr=new Date();this.setURLDef(vjp+hzw+"&sync="+jrr.getTime());};lng.selectNodes=function(nnq,rfmb){var gktb=new Array();if(rfmb==undefined)rfmb=this.getXML();if(AW.ie){var sns=rfmb.selectNodes(nnq);for(var ndk=0;ndk<sns.length;ndk++)gktb[ndk]=sns[ndk];}else{var ndk=0;var sns=this.getXML().evaluate(nnq,rfmb,null,XPathResult.ANY_TYPE,null);var xpdb=sns.iterateNext();while(xpdb){gktb[ndk++]=xpdb;xpdb=sns.iterateNext();}}return(gktb);};};AW.UI.SUBasicGrid=AW.UI.Grid.subclass();AW.UI.SUBasicGrid.create=function(){var lng=this.prototype;var pwm=this.superclass.prototype;lng.init=function(qmhb,nmrb,plf){pwm.init.call(this);this.setId(qmhb);this.setHeaderText(nmrb);this.setColumnCount(nmrb.length);this.setSelectionMode("multi-row");this.setSelectionMultiple(true);this.setStyle("width","100%");this.setStyle("height","297");this.setCellTemplate(new AW.Templates.ImageText,0);this.setStyle("position","static");var hvgb=new Array();for(var ndk=0;ndk<plf.length;ndk++){hvgb[ndk]=new AW.Formats.XMLString;this.setColumnWidth(plf[ndk],ndk);}this.setCellFormat(hvgb);this.m_dateLastSearch=0;this.m_sSearchStr="";};lng.UpdateText=function(vtp,ysjb,nffb){this.m_XMLTable.setData(vtp,ysjb,nffb);this.setCellText(undefined,ysjb,nffb);};lng.Update=function(hzw,mty,ycgb){this.setCellModel(this.m_XMLTable);this.m_bKeepState=(ycgb)?true:false;this.m_XMLTable.setURL(hzw);this.m_XMLTable.request(mty);};lng.PreUpdate=function(){this.m_nSortCol=this.getSortColumn();this.m_sSortDir=this.getSortDirection(this.m_nSortCol);if(typeof(this.m_fnPreUpdate)!="undefined")this.m_fnPreUpdate.call(this);return(true);};lng.PostUpdate=function(){this.setVirtualMode(this.getRowCount()>=100);if(this.m_nSortCol>=0)this.sort(this.m_nSortCol,this.m_sSortDir);this.ResetCurrentRow();if(typeof(this.m_fnPostUpdate)!="undefined"){this.m_fnPostUpdate.call(this);}};lng.ResetCurrentRow=function(){this.getRowIndices()?this.setCurrentRow(this.getRowIndices()[0]):this.setCurrentRow(0);this.setScrollTop(0);};lng.setCellModelDef=lng.setCellModel;lng.setCellModel=function(wkh){this.setCellModelDef.call(this,wkh);function mfkb(psx,cvw){var rbq=this.getCellData(psx,cvw);var ytg=this.getCellFormat(psx,cvw);return ytg?ytg.dataToText(rbq,this,psx,cvw):rbq;};function jbkb(psx,cvw){var rbq=this.getCellData(psx,cvw);var ytg=this.getCellFormat(psx,cvw);return ytg?ytg.dataToValue(rbq,this,psx,cvw):rbq;};this.setCellText(mfkb);this.setCellValue(jbkb);};lng.onHeaderClicked=function(Event,ndk){var tfkb;if((ndk==this.getSortColumn())&&((tfkb=this.getRowIndices())!="")){this.setSortDirection((this.getSortDirection(ndk)=="ascending")?"descending":"ascending",ndk);tfkb.reverse();this.setRowIndices(tfkb);return(true);}else return(false);};lng.onKeyPress=function(event){var dsz=String.fromCharCode(event.keyCode||event.charCode).toLocaleLowerCase();var pjvb=new Date().getTime();var rpm=this.getSortColumn();var zwb=this.getCellFormat(rpm);if((dsz!="")&&(rpm>=0)&&((!zwb)||(zwb.dataToValue("&",this,rpm,0)!="0"))){var qkwb=this.getRowIndices();var lks=0,nfh=this.getCurrentRow();var nzl=false;var lktb="";if(nfh>=0){for(var ndk in qkwb){if(qkwb[ndk]==nfh){lks=parseInt(ndk);break;}}}if((pjvb-this.m_dateLastSearch)>750){this.m_sSearchStr=dsz;if(lks)lks++;}else this.m_sSearchStr+=dsz;this.m_dateLastSearch=pjvb;if((!this.ItemSearch(this.m_sSearchStr,rpm,qkwb,lks,this.getRowCount()))&&(lks>0))this.ItemSearch(this.m_sSearchStr,rpm,qkwb,0,lks);}else{this.m_sSearchStr="";this.m_dateLastSearch=0;}};lng.ItemSearch=function(dvn,rpm,qkwb,kbz,lfpb){var nzl=false;for(var ndk=kbz;ndk<lfpb;ndk++){var lktb=this.getCellText(rpm,qkwb[ndk]).substring(0,dvn.length).toLocaleLowerCase();if(lktb==dvn){this.setSelectedRows([qkwb[ndk]]);this.setCurrentRow(qkwb[ndk]);nzl=true;break;}}return(nzl);};};function czsb(dtfb,jlvb,ftpb,equal,tqgb){return(function(psx,cvw){try{var dnbb=dtfb[psx];var tqm=dtfb[cvw];var dsj=false;var mkj;if(isNaN(dnbb)&&isNaN(tqm)){dnbb=dnbb.toLocaleLowerCase();tqm=tqm.toLocaleLowerCase();mkj=dnbb.localeCompare(tqm);}else dsj=true;if(!dsj){if(mkj>0){return jlvb}if(mkj<0){return ftpb}return equal(psx,cvw);}else{if(dnbb>tqm){return jlvb}if(dnbb<tqm){return ftpb}return equal(psx,cvw);}}catch(mls){return tqgb(psx,cvw,mls);}});}