📄 igf_grid.js
字号:
return result;};IgGridSection.prototype.getScrollingDiv=function(){var result=null;var tmp=this.getScrollingDivContent();if(!ig.isNull(tmp)){result=ig.getUIElementById(tmp.elm.parentNode);}
return result;};IgGridSection.prototype.getScrollingDivContent=function(){var result=null;var sec=this.getScrollingSection();if(!ig.isNull(sec)){result=ig.getUIElementById(sec.elm.parentNode);}
return result;};IgGridSection.prototype.getSubsection=function(col){var result=null;var rCount=this.getRowCount();if(rCount>0){var tr=this.getRow(rCount-1);if(!ig.isNull(tr)){var td=tr.elm.cells[col];if(!ig.isNull(td)){var tbls=td.getElementsByTagName("table");if(ig.isArray(tbls)&&tbls.length>0){result=new IgHtmlTable(tbls[0]);}}}}
return result;};IgGridSection.prototype.setColumnWidth=function(col,w,dnaac){if(ig.isNumber(col)&&ig.isNumber(w)){if(this.grid.isScrolling()){var fcc=this.grid.getFrozenColCount();if(col>=fcc){var scol=col-fcc;var sSec=this.getScrollingSection();sSec.setColumnWidth(scol,w);this.adjustSizeScrollingSection();}
else{var fSec=this.getFixedSection();fSec.setColumnWidth(col,w);this.adjustSizeFixedSection();this.adjustSizeScrollingSection();}}}};IgGridSection.prototype.scrollTo=function(x,y){var fixedDiv=this.getFixedDiv();var scrollDiv=this.getScrollingDiv();if(ig.isNumber(x)){if(!ig.isNull(scrollDiv)){if(scrollDiv.elm.scrollLeft!=x){scrollDiv.elm.scrollLeft=x;}}}
if(ig.isNumber(y)){if(!ig.isNull(scrollDiv)){if(scrollDiv.elm.scrollTop!=y){scrollDiv.elm.scrollTop=y;}}
if(!ig.isNull(fixedDiv)){if(fixedDiv.elm.scrollTop!=y){fixedDiv.elm.scrollTop=y;}}}};IgGridSection.prototype.setSize=function(w,h){this.adjustSizeFixedSection();this.adjustSizeScrollingSection();};ig.augment(IgGridSection,IgHtmlTable);function IgGridRow(e){this.IgUIElement(e);};IgGridRow.prototype.applyClass=function(){var css=this.getClass();if(ig.isString(css)){if(this.elm.className!=css){this.elm.className=css;}
var br=this.getSlaveRow();if(!ig.isNull(br)){if(br.elm.className!=css){br.elm.className=css;}}}};IgGridRow.prototype.collapse=function(){var cc=this.getChildContainer();if(!ig.isNull(cc)){cc.hide(true);ig.grid.onExpandRow(this);this.queueEvent(this.getId(),"expand","false");var expandedRows=document.getElementById(this.getGrid().elm.id+"_expandedRows");expandedRows.value=expandedRows.value.replace(this.elm.id,"");expandedRows.value=expandedRows.value.replace(" "," ");var sr=this.getSlaveRow();if(!ig.isNull(sr)){sr.collapse();}
this.getGrid().onScroll();}};IgGridRow.prototype.expand=function(){if(this.hasChild()){this.callSuper("IgUIElement","expand");ig.grid.onExpandRow(this);this.queueEvent(this.getId(),"expand","true");var expandedRows=document.getElementById(this.getGrid().elm.id+"_expandedRows");expandedRows.value=expandedRows.value+" "+this.elm.id;expandedRows.value=expandedRows.value.replace(" "," ");var sr=this.getSlaveRow();if(!ig.isNull(sr)){sr.expand();}}
else{var grid=this.getGrid();if(!ig.isNull(grid.getCurrentVirtualPage())){this.fireEvent("expand","scrollState:"+grid.getAttribute(ig.grid.PROP_LOD_MARKER_HEIGHT)+" "+grid.getCurrentVirtualPage(),ig.grid.onExpandedOnDemand,grid.getId());}else{if(!ig.isNull(grid.getBody().getScrollingDiv()))
this.fireEvent("expand","scrollState:"+grid.getBody().getScrollingDiv().elm.scrollTop,ig.grid.onExpandedOnDemand,grid.getId());else
this.fireEvent("expand",null,ig.grid.onExpandedOnDemand,grid.getId());}}};IgGridRow.prototype.getSlaveRow=function(suffix){if(ig.isNull(suffix)){suffix="_sr";}
var result=ig.getUIElementById(this.getId()+suffix);return result;};IgGridRow.prototype.inScrollingGrid=function(){return false;}
IgGridRow.prototype.getDefaultClass=function(){var result=this.getAttribute(ig.PROP_DEFAULT_CLASS,false);if(ig.isNull(result)){if(this.elm.nodeName=="TR"){if((this.elm.sectionRowIndex%2)===0){result=this.getAttribute(ig.PROP_DEFAULT_CLASS,true);}
else{result=this.getAttribute(ig.PROP_ALTERNATE_CLASS,true);}}}
return result;};IgGridRow.prototype.getGrid=function(){return ig.grid.getGrid(this.elm);};IgGridRow.prototype.select=function(){var rowSelector=this.getRowSelector();if(!ig.isNull(rowSelector)){rowSelector.checked=true;this.repaint();}};IgGridRow.prototype.getRowSelector=function(){var rowSelector=ig.findDescendant(this.elm,ig.PROP_FLAG,ig.grid.TYPE_GRID_ROW_SELECTOR);if(ig.isNull(rowSelector)){var slaveRow=this.getSlaveRow();if(!ig.isNull(slaveRow)){rowSelector=slaveRow.getRowSelector();}}
return rowSelector;};IgGridRow.prototype.unselect=function(){var rowSelector=this.getRowSelector();if(!ig.isNull(rowSelector)){rowSelector.checked=false;this.repaint();}};IgGridRow.prototype.updateJunctionIcon=function(anIcon){if(ig.NaES(anIcon)){var icon=ig.findDescendant(this.elm,null,null,"img");if(!ig.isNull(icon)&&icon.src!=anIcon){icon.src=anIcon;}}};IgGridRow.prototype.isSelected=function(){var result=false;var rowSelector=this.getRowSelector();if(ig.isNull(rowSelector)){var slaveRow=this.getSlaveRow();if(!ig.isNull(slaveRow)){rowSelector=slaveRow.getRowSelector();}}
if(!ig.isNull(rowSelector)){result=rowSelector.checked;}
return result;};IgGridRow.prototype.onClick=function(e){this.getGrid().onClick(e);};IgGridRow.prototype.onDoubleClick=function(e){this.getGrid().onDoubleClick(e);};ig.augment(IgGridRow,IgUIElement);function IgGridScrollingRow(e){this.IgGridRow(e);};IgGridScrollingRow.prototype.getChildContainer=function(){var id=this.getId();var sf=id.substr(id.length-3,3);id=id.substr(0,id.length-3);return ig.getUIElementById(id+"_cc"+sf);};IgGridScrollingRow.prototype.updateJunctionIcon=function(anIcon){if(ig.NaES(anIcon)){var icon=ig.findDescendant(this.elm,null,null,"img");if(!ig.isNull(icon)&&icon.src!=anIcon){icon.src=anIcon;}}};IgGridScrollingRow.prototype.onMouseEnter=function(){var master=this.getMaster();if(!ig.isNull(master)){ig.ui.setHoveredElement(master);}};IgGridScrollingRow.prototype.onMouseLeave=function(){ig.ui.setHoveredElement(null);};IgGridScrollingRow.prototype.getMaster=function(){var result=null;var mId=this.getId();if(ig.NaES(mId)){mId=mId.substr(0,mId.length-3);result=ig.getUIElementById(mId);}
return result;};IgGridScrollingRow.prototype.inScrollingGrid=function(){return true;}
IgGridScrollingRow.prototype.getGrid=function(){return ig.grid.getGrid(this.elm);};IgGridScrollingRow.prototype.onClick=function(e){this.getGrid().onClick(e);};IgGridScrollingRow.prototype.onDoubleClick=function(e){this.getGrid().onDoubleClick(e);};ig.augment(IgGridScrollingRow,IgGridRow);function IgGridColumnHeader(e){this.IgUIElement(e);};IgGridColumnHeader.prototype.getResizeMode=function(left,bottom,right,top){return this.isResizable()&&right?4:0;};IgGridColumnHeader.prototype.doResizeBegin=function(){this.orszwidh=0;var grid=ig.grid.getGrid(this.elm);var index=this.getIndex();if(!ig.isNull(grid)){var column=grid.getColumn(index);this.orszwidh=column.getWidth();}
grid.hideEditors();return null;};IgGridColumnHeader.prototype.doResizeMove=function(evt){var dx=ig.ui.x-ig.ui.mouseDownX;if(this.orszwidh+dx>0){var grid=ig.grid.getGrid(this.elm);var index=this.getIndex();var column=grid.getColumn(index);column.setWidth(this.orszwidh+dx,false);}
return null;};IgGridColumnHeader.prototype.doResizeEnd=function(){var grid=ig.grid.getGrid(this.elm);if(!ig.isNull(grid)){}};IgGridColumnHeader.prototype.doResizeStop=function(){var column=ig.grid.getGrid(this.elm).getColumn(this.getIndex());column.setWidth(this.orszwidh,false);};IgGridColumnHeader.prototype.getIndex=function(){var r=this.elm.cellIndex;if(this.isScrolling()){var g=ig.grid.getGrid(this.elm);if(!ig.isNull(g)){r+=g.getFrozenColCount();}}
return r;};IgGridColumnHeader.prototype.onDragOver=function(dea){this.showDropCaret(dea);};IgGridColumnHeader.prototype.onDrop=function(dea,dragSources){if(!ig.isNull(dragSources)){var grid=ig.grid.getGrid(this.elm);if(!ig.isNull(grid)){for(var i=0;i<dragSources.size();i++){var node=ig.getUIElementById(dragSources.get(i));if(!ig.isNull(node)){if(!this.equals(node)){var gridSrc=ig.grid.getGrid(node.elm);if(grid.equals(gridSrc)){var i=node.getIndex();var ni=this.getIndex();var ib=((dea.x-this.getPagePosition().x)<(this.getWidth()/2));if(!ib){ni=ni+1;}
if(ni>i){ni=ni-1;}
grid.moveColumn(i,ni);}}}}}}};IgGridColumnHeader.prototype.hideDropCaret=function(){this.callSuper("IgUIElement","hideDropCaret");var tmp=ig.getUIElementById("odrgfddbck");if(!ig.isNull(tmp)){tmp.removeNode();}};IgGridColumnHeader.prototype.isDragSourceAccepted=function(dragSources){var result=false;if(!ig.isNull(dragSources)){var table=this.elm.parentNode;if(!ig.isNull(table)){var t=this.getType();for(var i=0;i<dragSources.size();i++){var n=ig.getUIElementById(dragSources.get(i));if(n.getAttribute(ig.PROP_TYPE)===t){var table2=n.elm.parentNode;if(!(table===table2)||!this.isDraggable()){result=false;break;}}
else{result=false;break;}
result=true;}}}
return result;};IgGridColumnHeader.prototype.isScrolling=function(){return ig.NaES(this.getAttribute(ig.grid.PROP_IS_SCROLLING));};IgGridColumnHeader.prototype.getDropCaret=function(){var r=ig.getUIElementById("odrgfddbck");if(ig.isNull(r)){r=new IgDomNode(document.createElement("div"));r.elm.id="odrgfddbck";r.elm.className="igGridColumnCaret";r.setSize(null,this.getHeight());document.body.appendChild(r.elm);}
return r;};IgGridColumnHeader.prototype.showDropCaret=function(dea){this.callSuper("IgUIElement","showDropCaret",dea);var df=this.getDropCaret();if(!ig.isNull(df)){var pos=this.getPagePosition();var left=((dea.x-pos.x)<(this.getWidth()/2));if(left){df.moveTo(pos.x-1,pos.y);}
else{df.moveTo(pos.x+this.getWidth()-1,pos.y);}}};ig.augment(IgGridColumnHeader,IgUIElement);function IgGridColumn(grid,index){this.grid=grid;this.index=index;}
IgGridColumn.prototype.getWidth=function(){var acws=this.grid.getColumnWidthsAsArray();return acws[this.index];};IgGridColumn.prototype.isResizable=function(){var r=false;var hdr=this.grid.getColumnsHeader();if(!ig.isNull(hdr)){var rc=hdr.getRowCount();for(var ri=0;ri<rc;ri++){var aCell=hdr.getCell(ri,this.index);if(!ig.isNull(aCell)){if(aCell.isResizable()){r=true;break;}}}}
return r;};IgGridColumn.prototype.setWidth=function(w,dnaac){if(ig.isNumber(w)){var acws=this.grid.getColumnWidthsAsArray();acws[this.index]=w;var hdr=this.grid.getColumnsHeader();if(!ig.isNull(hdr)){if(this.index==acws.length-1&&this.grid.isScrolling()){if(ig.isIE)
hdr.setColumnWidth(this.index,w+this.grid.getScrollBarWidth()+2,dnaac);else
hdr.setColumnWidth(this.index,w+this.grid.getScrollBarWidth(),dnaac);}
else
hdr.setColumnWidth(this.index,w,dnaac);}
var bdy=this.grid.getBody();if(!ig.isNull(bdy)){bdy.setColumnWidth(this.index,w,dnaac);}
var ftr=this.grid.getColumnsFooter();if(!ig.isNull(ftr)){ftr.setColumnWidth(this.index,w,dnaac);}}};function IgGridCell(e,cellIndex){this.IgUIElement(e);this.cellIndex=cellIndex;}
IgGridCell.prototype.getIndex=function(){var row=this.getParentRow();var grid=this.getGrid()
var i=this.elm.cellIndex;if(grid.isScrolling()&&row.inScrollingGrid()){if(!ig.isNull(grid)){i+=grid.getFrozenColCount();}}
return i;};IgGridCell.prototype.getRowIndex=function(){var row=this.getParentRow();if(row.inScrollingGrid())
row=row.getMaster();var grid=this.getGrid();var rowIndex=0;var nestedRows=0;var rows=grid.getRows();if(ig.isArray(rows)){for(var i=0;i<rows.length;i++){var oflg=rows[i].getAttribute(ig.PROP_FLAG);if(oflg=="igNested"){nestedRows++;}
if(row.elm==rows[i]){rowIndex=i;break;}}}
return rowIndex-nestedRows;};IgGridCell.prototype.getColGroupCol=function(){var result=null;var tbl=ig.findAncestor(this.elm,null,null,"table");if(!ig.isNull(tbl)){var colGroups=tbl.getElementsByTagName("colgroup");if(ig.isArray(colGroups)){var cols=colGroups[0].getElementsByTagName("col");if(ig.isArray(cols)){if(cols.length>this.cellIndex){result=new IgDomNode(cols[this.cellIndex]);}}}}
return result;};IgGridCell.prototype.setWidth=function(w,dnaac){var r=new IgRect(0,0,w,0);this.convertBoxCoordinates(r,ig.ui.BOX_BORDER,this.getBoxingModel());var cgc=this.getColGroupCol();if(!ig.isNull(cgc)){if(ig.isIE){if(r.width>0){cgc.elm.width=r.width;}}
else{if(w>0){cgc.elm.width=w;}}}};IgGridCell.prototype.onClick=function(e){var grid=this.getGrid();grid.get_behaviors()._fireEvent(grid.getGrid().elm,e);ig.ui.setActiveComponent(grid);};IgGridCell.prototype.onDoubleClick=function(e){var grid=this.getGrid();grid.get_behaviors()._fireEvent(grid.getGrid().elm,e);ig.ui.setActiveComponent(grid);};IgGridCell.prototype.getGrid=function(){return ig.grid.getGrid(this.elm);};IgGridCell.prototype.getParentRow=function(){return ig.getUIElementById(this.elm.parentNode);;};IgGridCell.prototype.onMouseEnter=function(){this.getParentRow().onMouseEnter();};IgGridCell.prototype.get_value=function()
{var value=this.elm.getAttribute("val");if(!ig.isNull(value))
return value;return this.get_text();}
IgGridCell.prototype.set_value=function(value,text)
{var oldValue=this.get_value();var val=this.elm.getAttribute("val");if(!ig.isNull(val))
{val=value;this.elm.setAttribute("val",val);}
if(typeof(text)=="undefined")
text=value.toString();if(text!=oldValue){this.set_text(text);var grid=this.getGrid();var eventArguments="col:"+this.getIndex()+";row:"+this.getRowIndex()+";value:"+text;if(grid.getUpdateMode()=="cell"&&ig.grid.inSubmit!=true){grid.fireEvent("celledit",eventArguments,null,null);}else{grid.queueEvent(grid.getId(),"celledit",eventArguments);}}}
IgGridCell.prototype.get_text=function()
{var leaf=this.getFirstLeaf();var s=leaf.innerHTML;if(ig.isEmpty(s))
this.set_text(" ");s=s.replace(' ','');return s;}
IgGridCell.prototype.set_text=function(value)
{if(typeof(value)!="string")
value=""+value;if(ig.isEmpty(value))
value=" ";var leaf=this.getFirstLeaf();leaf.innerHTML=""+value;}
IgGridCell.prototype.getPosition=function(value){return new IgGridPosition(this.getRowIndex(),this.getIndex());}
ig.augment(IgGridCell,IgUIElement);ig.grid.init();}
function IgGridPosition(row,col){this.col=col;this.row=row;}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -