📄 grid.js
字号:
e.setCapture(true);
}
this.setWidth=function(col,w){
if (col<=0||col>=this.grid.rows.length+1) return 0;
return this.grid.rows(0).cells(col).width=w;
}
this.setDiv=function(fFixed){
if (fFixed){
this.id.style.overflow='auto';
this.id.style.width=this.width;
this.id.style.height=this.height;
this.id.style.borderWidth=0;
this.id.style.borderColor='#000000';
this.id.style.borderStyle=this.lineStyle;
}
else{
this.id.style.overflow=this.savedDiv.style.overflow;
this.id.style.width=this.savedDiv.style.width;
this.id.style.height=this.savedDiv.style.height;
this.id.style.borderWidth=this.savedDiv.style.borderWidth;
this.id.style.borderColor=this.savedDiv.style.borderColor;
this.id.style.borderStyle=this.savedDiv.style.borderStyle;
}
}
this.refresh=function(i,j,ft){
this.extobj.refresh(this.extobj,i,j,ft);
}
this.refreshAll=function(x,y,ft){
this.extobj.refreshAll(this.extobj,x,y,ft);
}
this.btnPageUp_onclick=function(){
var that=extobj.zydgrid;
extobj.GotoPos(extobj,that.showpos-that.rows);
}
this.btnPageDown_onclick=function(){
var that=extobj.zydgrid;
extobj.GotoPos(extobj,that.showpos+that.rows);
}
this.btnPosGoto_onclick=function(){
var that=extobj.zydgrid;
extobj.GotoPos(extobj,that.txtPosValue.value);
}
this.btnPosRemoveAll_onclick=function(){
var that=extobj.zydgrid;
that.data.length=0;
that.calcTotal();
that.refreshAll(1,0);
}
this.append=function(){
var data=this.data[this.data.length]=new Array();
for (var i=0;i<arguments.length&&i<cols;i++)
data[i]=arguments[i];
this.calcTotal();
if (this.data.length-this.rows>=0)this.showpos=this.data.length-this.rows;
}
this.remove=function(x){
var i;
if (x<this.data.length){
for (i=x;i<this.data.length;i++)
this.data[i]=this.data[i+1];
this.data.length--;
this.calcTotal();
}
}
this.savedDiv=document.createElement('DIV');
this.savedDiv.style.overflow=this.id.style.overflow;
this.savedDiv.style.width=this.id.style.width;
this.savedDiv.style.height=this.id.style.height;
this.savedDiv.style.borderWidth=this.id.style.borderWidth;
this.savedDiv.style.borderColor=this.id.style.borderColor;
this.savedDiv.style.borderStyle=this.id.style.borderStyle;
var nr,nc,i,j,title,zgi;
this.grid=document.createElement('TABLE');
this.grid.border=0;
this.grid.cellPadding=1;
this.grid.cellSpacing=0;
this.grid.style.borderColor='#000000';
this.grid.style.borderWidth=1;
this.grid.style.borderStyle=this.lineStyle;
this.grid.style.tableLayout='fixed';
this.grid.width=1;
for (i=0;i<=rows;i++){
nr=this.grid.insertRow(-1);
nr.bgColor=this.gridBgColor;
for (j=0;j<=cols;j++){
nc=nr.insertCell(-1);
//nc.noWrap=true;
if (i&&j){
nc.innerHTML=' ';
nc.style.cursor='default';
nc.style.borderColor='#A0A0A0';
nc.style.borderBottomWidth=1;
nc.style.borderBottomStyle=this.lineStyle;
nc.style.borderRightWidth=1;
nc.style.borderRightStyle=this.lineStyle;
nc.onmousemove=this.onmove;
nc.onmouseout=this.onout;
nc.onclick=this.onclick;
nc.oncontextmenu=this.oncontextmenu;
}
else{
title=(i==0?this.title:this.vtitle)
zgi=title[i==0?j:i]=new ZYDGRIDTITLE('','center',26,20,'#72c6ef','#000000',0);
nc.innerHTML=' ';
nc.width=zgi.width;
nc.height=zgi.height;
nc.bgColor=zgi.bgColor;
nc.style.cursor='default';
nc.style.color=zgi.color;
nc.align=zgi.align;
nc.style.borderTopColor=nc.style.borderLeftColor=this.GetLight(nc.bgColor);
nc.style.borderBottomColor=nc.style.borderRightColor=this.GetDark(nc.bgColor);
nc.style.borderWidth=1;
nc.style.borderStyle=this.lineStyle;
nc.onmousedown=this.onmousedown;
nc.onmouseup=this.onmouseup;
nc.onmousemove=this.onmousemove;
nc.onmouseout=this.onmouseout;
}
}
}
if (this.isTotalRow){
nr=this.grid.insertRow(-1);
nr.bgColor=this.gridBgColor;
for (j=0;j<=cols;j++){
nc=nr.insertCell(-1);
if (j==0)nc.innerHTML='∑';
else nc.innerHTML=' ';
nc.align='center';
nc.style.borderColor='#A0A0A0';
nc.style.borderTopColor='#000000';
nc.style.borderTopWidth=1;
nc.style.borderTopStyle=this.lineStyle;
nc.style.borderBottomWidth=1;
nc.style.borderBottomStyle=this.lineStyle;
nc.style.borderRightWidth=1;
nc.style.borderRightStyle=this.lineStyle;
}
}
this.id.appendChild(this.grid);
if (typeof(cb_getdataHTML)=='function') this.cb_getdataHTML=cb_getdataHTML;
this.btnPageUp=document.createElement('<input type=button>');
this.btnPageUp.value='上页';
this.btnPageUp.onclick=this.btnPageUp_onclick;
this.btnPageDown=document.createElement('<input type=button>');
this.btnPageDown.value='下页';
this.btnPageDown.onclick=this.btnPageDown_onclick;
this.txtPosValue=document.createElement('<input type=text>');
this.txtPosValue.value=this.showpos+1;
this.txtPosValue.onfocus=this.txtPosValue.select;
this.txtPosValue.size=6;
this.btnPosGoto=document.createElement('<input type=button>');
this.btnPosGoto.value='跳到记录';
this.btnPosGoto.onclick=this.btnPosGoto_onclick;
this.btnPosRemoveAll=document.createElement('<input type=button>');
this.btnPosRemoveAll.value='删除全部';
this.btnPosRemoveAll.onclick=this.btnPosRemoveAll_onclick;
this.pagectrl=document.createElement('TABLE');
this.pagectrl.style.display='none';
nr=this.pagectrl.insertRow(-1);
nc=nr.insertCell(-1);
nc.width=50;
nc.appendChild(this.btnPageUp);
nc=nr.insertCell(-1);
nc.width=50;
nc.appendChild(this.btnPageDown);
nc=nr.insertCell(-1);
nc.width=80;
nc.align='right';
nc.appendChild(this.txtPosValue);
nc=nr.insertCell(-1);
nc.width=50;
nc.appendChild(this.btnPosGoto);
/*nc=nr.insertCell(-1);
nc.width=140;
nc.align='right';
nc.appendChild(this.btnPosRemoveAll);*/
this.id.appendChild(this.pagectrl);
this.extobj.zydgrid=this;
}
function ZYDPAGECTRLFORIEBUG(){
this.obj=0;
this.GotoPage=function(that,x,dateFrom,dateTo,OwnerName){
var newpage;
if (isNaN(parseInt(x))){
that.txtPosValue.value=that.curpage;
return;
}
newpage=parseInt(x);
if (newpage>that.maxpage) newpage=that.maxpage;
if (newpage<1) newpage=1;
if (newpage==that.curpage) return;
requestSet('Page',newpage);
requestSet('t',new Date().valueOf());
requestSet('dateFrom',dateFrom);
requestSet('dateTo',dateTo);
requestSet('OwnerName',OwnerName);
setTimeout('location.replace(\''+requestGet()+'\');',100);
}
}
function ZYDPAGECTRL(extobj,id,curpage,maxpage,dateFrom,dateTo,OwnerName){
this.extobj=extobj;
this.extobj.obj=this;
this.id=id;
this.curpage=parseInt(curpage);
this.maxpage=parseInt(maxpage);
this.dateFrom=dateFrom
this.dateTo=dateTo
this.OwnerName=OwnerName
this.btnPageUp_onclick=function(){
var that=extobj.obj;
extobj.GotoPage(that,that.curpage-1,dateFrom,dateTo,OwnerName);
}
this.btnPageDown_onclick=function(){
var that=extobj.obj;
extobj.GotoPage(that,that.curpage+1,dateFrom,dateTo,OwnerName);
}
this.btnPosGoto_onclick=function(){
var that=extobj.obj;
extobj.GotoPage(that,that.txtPosValue.value,dateFrom,dateTo,OwnerName);
}
this.btnReturn_onclick=function(){
setTimeout('try{IClient(\'end\',\'\');}catch(e){}',100);
}
this.btnPageUp=document.createElement('<input type=button>');
this.btnPageUp.value='上页';
if (curpage==1) this.btnPageUp.disabled=true;
this.btnPageUp.onclick=this.btnPageUp_onclick;
this.btnPageDown=document.createElement('<input type=button>');
this.btnPageDown.value='下页';
if (curpage==maxpage) this.btnPageDown.disabled=true;
this.btnPageDown.onclick=this.btnPageDown_onclick;
this.txtPosValue=document.createElement('<input type=text>');
this.txtPosValue.value=this.curpage;
this.txtPosValue.onfocus=this.txtPosValue.select;
this.txtPosValue.size=6;
this.btnPosGoto=document.createElement('<input type=button>');
this.btnPosGoto.value='转到';
this.btnPosGoto.onclick=this.btnPosGoto_onclick;
this.btnReturn=document.createElement('<input type=button>');
this.btnReturn.value='返回';
this.btnReturn.onclick=this.btnReturn_onclick;
this.pagectrl=document.createElement('TABLE');
var nr,nc;
nr=this.pagectrl.insertRow(-1);
nc=nr.insertCell(-1);
nc.noWrap=true;
nc.appendChild(this.btnPageUp);
nc.appendChild(document.createTextNode(' '));
nc.appendChild(this.btnPageDown);
nc.appendChild(document.createTextNode(' 共'+this.maxpage+'页 第'));
nc.appendChild(this.txtPosValue);
nc.appendChild(document.createTextNode('页 '));
nc.appendChild(this.btnPosGoto);
nc.appendChild(document.createTextNode(' '));
nc.appendChild(this.btnReturn);
this.id.appendChild(this.pagectrl);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -