📄 igf_grid.js
字号:
{paddingTop=scrollingRowsParent.childNodes[0].childNodes[0].currentStyle['paddingTop'];paddingBottom=scrollingRowsParent.childNodes[0].childNodes[0].currentStyle['paddingBottom'];}
singleRowHeight-=parseInt(paddingTop)+parseInt(paddingBottom);var cheader=this.getColumnsHeader();var rows=cheader.elm.rows;ig.getUIElementById(rows[0]).setSize(null,singleRowHeight);var header=document.getElementById(this.elm.id+"_cheaders_sr");if(!ig.isNull(header))
ig.getUIElementById(header).setSize(null,singleRowHeight);var header=document.getElementById(this.elm.id+"_cheaders");if(!ig.isNull(header))
ig.getUIElementById(header).setSize(null,singleRowHeight);if(fixedColumnsCount>0)
{fixedRowsParent=this.getBody().getFixedSection().elm.childNodes[0];for(var i=0;i<fixedRowsParent.childNodes.length;i++)
{if(fixedRowsParent.childNodes[i].id.indexOf("_cc")==-1){fixedRowsParent.childNodes[i].style.height=singleRowHeight;}else{fixedRowsParent.childNodes[i].style.height=fixedRowsParent.childNodes[i].offsetHeight;}}}
for(var i=0;i<scrollingRowsParent.childNodes.length;i++)
{scrollingRowsParent.childNodes[i].style.height=singleRowHeight;}}
var addScrollWidthToBody=false;if(udw==0&&(udh>0&&udh<=gh))
{if(!ig.isIE){this.getGridContainer().elm.style["width"]=gw+this.getScrollBarWidth()+2+"px";}else{this.getGridContainer().elm.style["width"]=gw+this.getScrollBarWidth()+"px";}}else if(udw==0&&(udh>0&&udh>gh))
{this.getGridContainer().elm.style["width"]=gw+"px";}
if(udh==0&&(udw>0&&udw<gw))
{if(!ig.isIE){var header=document.getElementById(this.elm.id+"_cheaders");if(header!=null)
this.getGridContainer().elm.style["height"]=gh+this.getScrollBarWidth()+header.offsetHeight-5+"px";else
this.getGridContainer().elm.style["height"]=gh+this.getScrollBarWidth()+"px";addScrollWidthToBody=true;}else{addScrollWidthToBody=true;}}else if(udh==0&&(udw>0&&udw>gw))
{this.getGridContainer().elm.style["height"]=gh+"px";if(!ig.isIE){this.elm.setStyle["height"]=gh+"px";}
else{this.elm.style["height"]=gh+"px";}}
if(udw>0&&!widthUsesPercentages){gw=udw;}
if(udh>0&&!heightUsesPercentages){gh=udh;}
if(udh>0&&udh-this.getScrollBarWidth()>0){var topPager=document.getElementById(this.elm.id+":topPager");if(topPager){var height=gh+this.getGridTopPager().elm.offsetHeight;this.getGridContainer().elm.style['height']=height+"px";}else{this.getGridContainer().setSize(null,gh);}}
if(ig.isIE&&udh==0&&udw==0)
{this.elm.style["width"]=gw+"px";}
this.setSize(gw,gh,addScrollWidthToBody);var virtualLoadOnDemand=this.getAttribute(ig.grid.PROP_IS_LOAD_ON_DEMAND);if(!ig.isNull(virtualLoadOnDemand))
{function findPos(obj){var curleft=curtop=0;if(obj.offsetParent){curleft=obj.offsetLeft;curtop=obj.offsetTop;while(obj=obj.offsetParent){curleft+=obj.offsetLeft;curtop+=obj.offsetTop;}}
return[curleft,curtop];};var pos=findPos(this.getBody().elm);this.setAttribute("onScrollMonitor",false);if(virtualLoadOnDemand==ig.grid.LOAD_ON_DEMAND_PARTITIONED)
{var partitionedRowCount=this.getAttribute(ig.grid.PARTITIONED_ROW_COUNT);var singleRowHeight=this.getSingleRowHeight();var currentVirtualPage=this.getCurrentVirtualPage();var virtualPageCount=this.getAttribute(ig.grid.PROP_IG_VIRTUAL_PAGE_COUNT);this.getBody().getScrollingDivContent().setSize(null,partitionedRowCount*singleRowHeight);this.getBody().getFixedDivContent().setSize(null,partitionedRowCount*singleRowHeight);var needLodMarker=false;var scrollingContent=this.getBody().getScrollingDivContent();var fixedContent=this.getBody().getFixedDivContent();var fetchSize=this.getAttribute(ig.grid.PROP_IG_ROW_FETCH_SIZE);if(!ig.isNull(currentVirtualPage)&¤tVirtualPage!=0)
{needLodMarker=true;}
this.setAttribute(ig.grid.PROP_LOD_MARKER_HEIGHT,0);if(needLodMarker){lodMarker=document.createElement("div");lodMarker.id="lodMarker";var lodMarkerHeight=currentVirtualPage*fetchSize*singleRowHeight;lodMarkerHeight=this.getAttribute(ig.grid.PROP_IG_SCROLL_TOP_STATE);this.setAttribute(ig.grid.PROP_LOD_MARKER_HEIGHT,lodMarkerHeight);if(ig.isIE||ig.isOpera)
lodMarker.style.height=lodMarkerHeight;else
lodMarker.style.height=lodMarkerHeight+"px;";scrollingContent.elm.insertBefore(lodMarker,scrollingContent.elm.firstChild);fixedContent.elm.insertBefore(lodMarker.cloneNode(true),fixedContent.elm.firstChild);}
var virtualPageIndex=document.createElement("div");virtualPageIndex.id=this.elm.id+"_virtualPageIndex";virtualPageIndex.style.position="relative";virtualPageIndex.style.border="solid 1px";virtualPageIndex.style.display="inline";virtualPageIndex.style.visibility="hidden";var virtualPageCount=this.getAttribute(ig.grid.PROP_IG_VIRTUAL_PAGE_COUNT);var virtualPageText=document.createTextNode("0 / "+virtualPageCount);virtualPageIndex.appendChild(virtualPageText);this.elm.appendChild(virtualPageIndex);virtualPageIndex.style.left=this.getBody().getSize().width-ig.grid.PROP_IG_LOAD_ON_DEMAND_TOOLTIP_OFFSET+"px";virtualPageIndex.style.top=-this.getBody().getSize().height/2+"px";}
var loadingImage=document.createElement("img");loadingImage.setAttribute("src",this.getAttribute(ig.grid.PROP_IG_LOADING_IMAGE));var loadingDiv=document.createElement("div");loadingDiv.id=this.elm.id+"_loadingDiv";loadingDiv.appendChild(loadingImage);this.elm.appendChild(loadingDiv);loadingDiv.style.position="relative";loadingDiv.style.visibility="hidden";}
if(ig.isOpera)
this.scrollTo(0,0);}}};IgGrid.prototype.isScrolling=function(){return ig.NaES(this.getAttribute(ig.grid.PROP_IS_SCROLLING));};IgGrid.prototype.isImmediateRowsChangeEvent=function(){return ig.NaES(this.getAttribute("igirce"));};IgGrid.prototype.moveColumn=function(fci,tci){fci=ig.toFloat(fci);tci=ig.toFloat(tci);if(!isNaN(fci)&&!isNaN(tci)){if(fci>=0&&tci>=0&&fci!=tci){this.resetEditors();ig.smartSubmit(this.elm.id,"moveColumn","fci:"+fci+";tci:"+tci,this.elm.id);}}};IgGrid.prototype.resetEditors=function(){var editing=this.get_behaviors().getBehaviorFromInterface($IG.IEditingBehavior);if(editing!=null){editing.resetEditors();}}
IgGrid.prototype.hideEditors=function(){var editing=this.get_behaviors().getBehaviorFromInterface($IG.IEditingBehavior);if(editing!=null){editing.hideEditors();}}
IgGrid.prototype.onBeforeSubmit=function(evt){this.get_behaviors()._fireEvent(this.elm,evt);}
IgGrid.prototype.needScrollingGrid=function(){var w=ig.toFloat(this.getStyleInline("width"));var h=ig.toFloat(this.getStyleInline("height"));return(this.hasResizableColumn()||w>0||h>0)&&!this.isScrolling();};IgGrid.prototype.onResize=function(){};IgGrid.prototype.onLoadOnDemand=function(httpReq){var xmlDoc=httpReq.getResponseXml();if(!ig.isNull(xmlDoc)){var results=xmlDoc.documentElement;if(!ig.isNull(results)){var components=results.getElementsByTagName("component");for(var i=0;i<components.length;i++){var component=components.item(i);var componentId=component.getAttribute("id");if(ig.NaES(componentId)){var currentComponent=ig.getElementById(componentId);if(!ig.isNull(currentComponent)){var content=component.getElementsByTagName("content").item(0);var existingGrid=ig.grid.getGrid(document.getElementById(componentId));var contentAsHtml=(!ig.isNull(content.firstChild))?content.firstChild.nodeValue:"";var existingRowsParent=existingGrid.getBody().getScrollingSection().elm.childNodes[0];var fixedColumnsCount=existingGrid.getFrozenColCount();var fixedRowsParent=null;if(fixedColumnsCount>0)
{fixedRowsParent=existingGrid.getBody().getFixedSection().elm.childNodes[0];}
var aDiv=document.createElement("div");document.body.appendChild(aDiv);aDiv.innerHTML=contentAsHtml;var newGrid=ig.findDescendant(aDiv,"id",componentId);var newGridBody=ig.findDescendant(aDiv,"id",componentId+"_body");var newRows=newGridBody.rows;var rowSize=newRows.length;for(var ridx=0;ridx<rowSize;ridx++)
{var tmpRow=newRows[ridx].cloneNode(true);if(fixedColumnsCount>0){var fixedTr=ig.getUIElementById(document.createElement("TR"));var rheight=existingGrid.getSingleRowHeight();var tmpId=tmpRow.id;tmpRow.id=tmpId+"_sr";tmpRow.setAttribute("otype","GridRowScroll");fixedTr.elm.id=tmpId;fixedTr.elm.className=tmpRow.className;fixedTr.elm.setAttribute("otype","GridRow");ig.getUIElementById(tmpRow).setSize(null,rheight);fixedTr.setSize(null,rheight);for(var fi=0;fi<fixedColumnsCount;fi++){fixedTr.elm.appendChild(tmpRow.childNodes[0].cloneNode(true));ig.deleteNode(tmpRow.childNodes[0]);}
fixedRowsParent.appendChild(fixedTr.elm);existingRowsParent.appendChild(tmpRow);}else{existingRowsParent.appendChild(tmpRow);}}
for(var attr=0;attr<newGrid.attributes.length;attr++)
{if(newGrid.attributes[attr].nodeName!="style"){existingGrid.elm.setAttribute(newGrid.attributes[attr].nodeName,newGrid.attributes[attr].nodeValue);}}
ig.deleteNode(aDiv);var scrollTopState=existingGrid.getAttribute(ig.grid.PROP_IG_SCROLL_TOP_STATE);if(!ig.isNull(scrollTopState)){existingGrid.isScrollingGrid=true;}
if(!ig.isNull(scrollTopState))
existingGrid.setScrollTop(scrollTopState);var loadingDiv=document.getElementById(existingGrid.elm.id+"_loadingDiv");loadingDiv.style.visibility="hidden";}}}}
var clientState=results.getElementsByTagName("state").item(0);if(!ig.isNull(clientState)){var clientStateContent=clientState.getElementsByTagName("content").item(0);if(!ig.isNull(clientStateContent)){var clientStateAsHtml=(!ig.isNull(clientStateContent.firstChild))?clientStateContent.firstChild.nodeValue:"";var parsedClientState=ig.parseHtml(clientStateAsHtml,false);if(!ig.isNull(parsedClientState)){var nodes=parsedClientState.childNodes;for(var k=nodes.length-1;k>=0;k--){var aNode=nodes.item(k);if(aNode.nodeName=="INPUT"){var id=aNode.id;var currentNode=null;if(ig.NaES(id)){currentNode=document.getElementById(id);}
else{var name=aNode.name;var elements=document.getElementsByName(name);if(elements.length==1){currentNode=elements[0];}}
if(!ig.isNull(currentNode)){ig.replaceNode(currentNode,aNode);}}}
ig.deleteNode(parsedClientState);}}}}};IgGrid.prototype.onScroll=function(){var loadOnDemand=this.getAttribute(ig.grid.PROP_IS_LOAD_ON_DEMAND);if(!ig.isNull(this.getAttribute("onScrollMonitor"))&&this.getAttribute("onScrollMonitor")=="false"){this.setAttribute("onScrollMonitor",true);var id=this.elm.id;id=id.replace(/:/,"_");if(loadOnDemand==ig.grid.LOAD_ON_DEMAND_DEFAULT){ig.grid.instancesIds[id]=setInterval('ig.grid.instances[\''+id+'\'].onScrollEndDefault()',ig.grid.PROP_IG_LOAD_ON_DEMAND_TIMER_DEFAULT);}else if(loadOnDemand==ig.grid.LOAD_ON_DEMAND_PARTITIONED){ig.grid.instancesIds[id]=setInterval('ig.grid.instances[\''+id+'\'].onScrollEnd()',ig.grid.PROP_IG_LOAD_ON_DEMAND_TIMER_PARTITIONED);}}
var body=this.getBody();if(!ig.isNull(body)){var bodyScrollDiv=body.getScrollingDiv();if(!ig.isNull(bodyScrollDiv)){this.scrollTo(bodyScrollDiv.elm.scrollLeft,bodyScrollDiv.elm.scrollTop);}
if(ig.isNull(loadOnDemand))
return;else if(loadOnDemand==ig.grid.LOAD_ON_DEMAND_PARTITIONED){var virtualPageIndex=document.getElementById(this.elm.id+"_virtualPageIndex");virtualPageIndex.style.visibility="visible";var grid=ig.grid.getGrid(this);var body=grid.getBody();if(!ig.isNull(body)){var bodyScrollDiv=body.getScrollingDiv();var scrollTop=parseInt(bodyScrollDiv.elm.scrollTop);var singleRowHeight=parseInt(grid.getSingleRowHeight());var fetchSize=parseInt(this.getAttribute(ig.grid.PROP_IG_ROW_FETCH_SIZE));var excludedHeight=0;var expandedRows=document.getElementById(this.elm.id+"_expandedRows");if(expandedRows!=null){expandedRows=expandedRows.value.split(" ");if(expandedRows!=""){for(var i=0;i<expandedRows.length;i++)
{if(expandedRows[i]!=""&&!ig.isNull(expandedRows[i])){var row=document.getElementById(expandedRows[i]+"_cc_sr");if(row!=null){excludedHeight+=row.offsetHeight;}}}}}
var currentlyAt=parseInt((scrollTop-excludedHeight)/singleRowHeight);var currentVirtualPage=0;currentVirtualPage=parseInt(currentlyAt/fetchSize);currentVirtualPage++;if(currentVirtualPage>grid.getAttribute(ig.grid.PROP_IG_VIRTUAL_PAGE_COUNT))
currentVirtualPage=grid.getAttribute(ig.grid.PROP_IG_VIRTUAL_PAGE_COUNT);else if(currentVirtualPage==0)
currentVirtualPage++;virtualPageIndex.childNodes[0].nodeValue=" "+currentVirtualPage+" / "+grid.getAttribute(ig.grid.PROP_IG_VIRTUAL_PAGE_COUNT)+" ";}}}};IgGrid.prototype.getCurrentVirtualPage=function(){return this.getAttribute("currentVirtualPage");};IgGrid.prototype.setCurrentVirtualPage=function(page){this.setAttribute("currentVirtualPage",page);};IgGrid.prototype.setScrollTop=function(scrollTop)
{var body=this.getBody();var bodyScrollDiv=body.getScrollingDiv();bodyScrollDiv.elm.scrollTop=scrollTop;};IgGrid.prototype.selectAllRows=function(select){var rows=this.getRows();if(ig.isArray(rows)){for(var i=0;i<rows.length;i++){var aRow=ig.getUIElementById(rows[i]);type=ig.getType(aRow);if(type=="GridRow"){if(select===true){aRow.select();}
else{aRow.unselect();}}}}};IgGrid.prototype.setColumnWidthsAsArray=function(w){if(ig.isArray(w)){this.elm["igArrColWidths"]=w;}};IgGrid.prototype.setSize=function(w,h,addScrollWidthToBody){var bodyHeight=null;var chdr=this.getColumnsHeader();var cftr=this.getColumnsFooter();if(ig.isNumber(h)){bodyHeight=h;var ghdr=this.getGridHeader();if(!ig.isNull(ghdr)){bodyHeight=bodyHeight-ghdr.getHeight();}
if(!ig.isNull(chdr)){bodyHeight=bodyHeight-chdr.getHeight();}
if(!ig.isNull(cftr)){bodyHeight=bodyHeight-cftr.getHeight();}
var gftr=this.getGridFooter();if(!ig.isNull(gftr)){bodyHeight=bodyHeight-gftr.getHeight();}}
if(!ig.isNull(chdr)){chdr.setSize(w,null);}
var bdy=this.getBody();if(!ig.isNull(bdy)){if(ig.isNumber(bodyHeight)){var bsd=bdy.getScrollingDiv();if(!ig.isNull(bsd)){if(addScrollWidthToBody){if(ig.isIE)
{bsd.elm.style['height']=bodyHeight+this.getScrollBarWidth()+document.getElementById(this.elm.id+"_cheaders").offsetHeight-10+"px";}else{bsd.elm.style['height']=bodyHeight+this.getScrollBarWidth()+"px";}}
else{bsd.setSize(null,bodyHeight);}}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -