?? grids.js
字號(hào):
this._selectionModel.handleMouseUp(node,e);break;case"click":this._selectionModel.handleClick(node,e);break;case"dblclick":if(node&&node.hasNodes()){node.toggle();if(node.getExpanded())
node._scrollSubtreeIntoView();}
else this._selectionModel.handleDblClick(node,e);break;}};_p._onKeyDown=function(e){var leadItem=this._selectionModel.getLeadItem();if(leadItem){switch(e.getKeyCode()){case BiKeyboardEvent.RIGHT:if(leadItem.hasNodes()){if(leadItem.getExpanded())
this._selectionModel.setLeadItem(leadItem.getFirstNode());else{leadItem.setExpanded(true);leadItem._scrollSubtreeIntoView();}}
break;case BiKeyboardEvent.LEFT:if(leadItem.hasNodes()&&leadItem.getExpanded())
leadItem.setExpanded(false);else{var p=leadItem.getParentNode();if(p==leadItem.getTree())
break;this._selectionModel.setLeadItem(p);}
break;}}
this._selectionModel.handleKeyDown(e);};_p.getExpanded=function(){return true;};_p.setExpanded=function(b){};_p.reveal=function(){};_p._sort=function(fCompare,bAscending){if(this.hasNodes()){for(var i=0;i<this._nodes.length;i++)
this._nodes[i]._sort(fCompare,bAscending);this._nodes.sort(fCompare);if(!bAscending)
this._nodes.reverse();}};_p.getRowAtPoint=_p.getNodeAtPoint=function(nClientX,nClientY){var el=this._document.elementFromPoint(nClientX,nClientY);if(el==null)return null;var res=this._getMouseEventInfo(null,el);return res?res.treeNode:null;};function BiTreeNode(oData){BiAbstractGridRow.call(this);this._nodes=[];this._data=oData||[];}
var _p=BiTreeNode.prototype=new BiAbstractGridRow;_p._className="BiTreeNode";_p._indentWidth=19;_p._expanded=true;_p._icon=BiTree.DEFAULT_ICON;_p.getData=function(nCol){return this._data[nCol];};_p.setData=function(nCol,oData){this._data[nCol]=oData;};_p.matchesString=function(sText){return sText!=""&&BiLabel.htmlToText(this.getCellHtml(0).toLowerCase()).
indexOf(sText.toLowerCase())==0;};_p.matchesStringExact=function(sText){return sText!=""&&BiLabel.htmlToText(this.getCellHtml(0)).toLowerCase()==String(sText).toLowerCase();};_p.getHtml=function(){var childrenHtml;if(this.hasNodes()){var childrenSb=[];var cs=this._nodes;var l=cs.length;for(var y=0;y<l;y++)
childrenSb[y]=cs[y].getHtml();childrenHtml="<div class=\"bi-tree-children\" style=\""+this._getLineStyle()+(this.getExpanded()?"":"display:none;")+"\">"+childrenSb.join("")+"</div>"}
else childrenHtml="";return"<div class=\"bi-tree-node\" id=\""+this.toHashCode()+"\">"+this.getRowHtml()+childrenHtml+"</div>";};_p.getRowHtml=function(){var tree=this.getTree();var cellsSb=[];var l=tree._columnCount;for(var x=0;x<l;x++)
cellsSb[x]=this.getCellHtml(tree._columnOrders[x]);return"<div class=\""+this.getCssClassName()+"\""+this._getStyle()+">"+cellsSb.join("")+"</div>";};_p.getCssClassName=function(){var f=this._grid&&this._grid.getFocused();return"bi-tree-row"+(this._selected&&f?" selected-tree-node-focused":"")+(this._selected&&!f?" selected-tree-node":"");};_p.getCellHtml=function(nCol){var t=this.getTree();return"<span class=\"bi-tree-cell col-"+nCol+"\">"+(nCol==t.getIndentColumn()?this.getExpandIconHtml():"")+(nCol==t.getIconColumn()?this.getIconHtml():"")+this.getLabelHtml(nCol)+"</span>";};_p.getLabelHtml=function(nCol){return this._data[nCol];};_p.getIconHtml=function(){var i=this.getIcon();if(!i)return"";if(i.getIconHtml)
return i.getIconHtml(this.getLabelHtml()!="",true,"left",3,"bi-tree-icon");else return"<img class=\"bi-tree-icon\" src=\""+i+"\">";};_p.getExpandIconSrc=function(){var src;var tree=this.getTree();if(this.hasNodes()){if(!tree.getShowLines()||this.getLevel()==1&&!tree.getShowRootLines()){if(!tree.getShowPlusMinus())
src=BiTree.BLANK_ICON;else if(this.getExpanded())
src=BiTree.MINUS_ICON;else src=BiTree.PLUS_ICON;}
else if(this.isLastSiblingNode()){if(!tree.getShowPlusMinus())
src=BiTree.L_ICON;else if(this.getExpanded())
src=BiTree.L_MINUS_ICON;else src=BiTree.L_PLUS_ICON;}
else{if(!tree.getShowPlusMinus())
src=BiTree.T_ICON;else if(this.getExpanded())
src=BiTree.T_MINUS_ICON;else src=BiTree.T_PLUS_ICON;}}
else{if(!this.getTree().getShowLines()||this.getLevel()==1&&!tree.getShowRootLines())
src=BiTree.BLANK_ICON;else if(this.isLastSiblingNode())
src=BiTree.L_ICON;else src=BiTree.T_ICON;}
return src;};_p.getExpandIconHtml=function(){if(!this.getTree().getShowPlusMinus()&&!this.getTree().getShowLines())
return"";return"<img class=\"bi-tree-expand-icon\" src=\""+this.getExpandIconSrc()+"\">";};_p._getLineStyle=function(){return!this._getShowChildrenLine()?"background-position: -100px 0 !important;":"";};_p._getShowChildrenLine=function(){var tree=this.getTree();return tree.getShowLines()&&!this.isLastSiblingNode()&&!(!tree.getShowRootLines()&&this.getLevel()==1);};_p.update=function(){BiAbstractGridRow.prototype.update.call(this);this.getTree()._updateHeadersWidth();};_p.updateRow=function(){if(!this.getCreated()||!this.getTree())return;if(BiBrowserCheck.ie)
this._element.firstChild.outerHTML=this.getRowHtml();else {var dummy=this.getTree()._document.createElement("DIV");dummy.innerHTML=this.getRowHtml();this._element.firstChild.parentNode.replaceChild(dummy.firstChild,this._element.firstChild);}
this.getTree()._clearCache();};_p.addNode=function(oChild,oBefore){var p=oChild._parentNode;if(oBefore==null){if(p!=null)
p.removeNode(oChild);this._nodes.push(oChild);}
else{if(oBefore._parentNode!=this)
throw new Error("Can only add components before siblings");if(p!=null)
p.removeNode(oChild);var i=this._nodes.indexOf(oBefore);this._nodes.insertAt(oChild,i);}
oChild._parentNode=this;if(this.getTree()){oChild._grid=this.getTree();oChild._grid._clearCache();}
if(this.getLevel()!=null)
oChild._level=this.getLevel()+1;};_p.removeNode=function(oChild){if(oChild._parentNode!=this)
throw new Error("Can only remove children");this._nodes.remove(oChild);oChild._parentNode=null;if(oChild._grid){oChild._grid._clearCache();}
oChild._grid=null;oChild._level=null;return oChild;};_p.removeAll=function()
{var cs=this.getChildren();var l=cs.length;for(var i=0;i<l;i++)
{this.remove(cs[i]);cs[i].dispose();}};BiTreeNode.prototype.getParentNode=function(){return this._parentNode;};_p.getNodes=function(){return this._nodes;};_p.containsNode=function(oDescendant){if(oDescendant==null)return false;if(oDescendant==this)return true;var p=oDescendant._parentNode;return this.containsNode(p);};_p.getFirstNode=function(){return this._nodes[0];};_p.getLastNode=function(){return this._nodes[this._nodes.length-1];};_p.getPreviousSiblingNode=function(){var p=this._parentNode;if(p==null)return null;var cs=p._nodes;return cs[cs.indexOf(this)-1]};_p.getNextSiblingNode=function(){var p=this._parentNode;if(p==null)return null;var cs=p._nodes;return cs[cs.indexOf(this)+1]};_p.getLevel=function(){if(this._level!=null)
return this._level;if(this._parentNode){var pd=this._parentNode.getLevel();return this._level=(pd!=null?pd+1:null);}
return null;};_p.hasNodes=function(){return this._nodes.length>0;};_p.isLeaf=function(){return!this.hasNodes();};_p.getGrid=_p.getTree=function(){if(this._grid)
return this._grid;if(this._parentNode)
return this._grid=this._parentNode.getTree();return null;};_p.getDepth=function(){var d=0;var cs=this._nodes;var l=cs.length;for(var i=0;i<l;i++)
d=Math.max(d,cs[i].getDepth()+1);return d;};_p.isLastSiblingNode=function(){return this._parentNode&&this==this._parentNode.getLastNode();};_p.getExpanded=function(){return this._expanded;};_p.dispose=function(){if(this._disposed)return;for(var i=this._nodes.length-1;i>=0;i--)
this._nodes[i].dispose();this._element=null;this._grid=null;this._disposed=true;};_p._sort=function(fCompare,bAscending){if(this.hasNodes()){for(var i=0;i<this._nodes.length;i++)
this._nodes[i]._sort(fCompare,bAscending);this._nodes.sort(fCompare);if(!bAscending)
this._nodes.reverse();}};_p._getAllNodes=function(oHash){oHash[this.toHashCode()]=this;var cs=this._nodes;var l=cs.length;for(var i=0;i<l;i++)
cs[i]._getAllNodes(oHash);};BiTreeNode.prototype.getExpanded=function(){return this._expanded;};_p.setExpanded=function(b){if(this._expanded!=b){if(!this.hasNodes()){this._expanded=false;return;}
this._expanded=b;if(this.getCreated()){var rowEl=this._element.firstChild;var childrenEl=this._element.lastChild;if(BiBrowserCheck.ie)
rowEl.outerHTML=this.getRowHtml();else {var dummy=rowEl.ownerDocument.createElement("DIV");dummy.innerHTML=this.getRowHtml();rowEl.parentNode.replaceChild(dummy.firstChild,rowEl);}
childrenEl.style.display=b?"":"none";}
var tree=this.getTree();if(tree){if(!b)
tree._selectionModel._collapseNode(this);tree._updateHeadersWidth();}}};_p.reveal=function(){var p=this.getParentNode()
if(p){p.setExpanded(true);p.reveal();}};_p.toggle=function(){this.setExpanded(!this.getExpanded());};_p._scrollSubtreeIntoView=function(){if(!this.getCreated()){return;}
var p=this.getGrid();if(!p)return;var t=this.getTop();var st=p.getScrollTop();var ch=p.getClientHeight();var fh=p._getFillerHeight();var last=BiTreeHelper.getLastShownDescendant(this);var lastTop=last.getTop();var lastHeight=last.getHeight();var h=lastTop+lastHeight-t;if(h>ch||t-fh<st)
p.setScrollTop(t-fh);else if(t+h>st+ch)
p.setScrollTop(t+h-ch);};function BiTreeHelper(){BiObject.call(this);}
var _p=BiTreeHelper.prototype=new BiObject;_p._className="BiTreeHelper";BiTreeHelper.getLastShownDescendant=function(n){if(!n.getExpanded()||n.isLeaf())
return n;return BiTreeHelper.getLastShownDescendant(n.getLastNode());};BiTreeHelper.getNextShownNode=function(n){var cs=n.getNodes();if(cs.length>0&&n.getExpanded())
return cs[0];else{var p=n;var next;while(p!=null){next=p.getNextSiblingNode();if(next!=null)
return next;p=p.getParentNode();}
return null;}};BiTreeHelper.getPreviousShownNode=function(n){var ps=n.getPreviousSiblingNode();if(ps!=null){return BiTreeHelper.getLastShownDescendant(ps);}
var p=n.getParentNode();return p!=n.getTree()?n.getParentNode():null;};BiTreeHelper.getPreorderShownNodes=function(n){var res=[];BiTreeHelper._getPreorderShownNodes(n,res);return res;};BiTreeHelper._getPreorderShownNodes=function(n,arr){if(n!=n.getTree())
arr.push(n);if(n.getExpanded()){for(var i=0;i<n._nodes.length;i++)
BiTreeHelper._getPreorderShownNodes(n._nodes[i],arr);}};BiTreeHelper.isBefore=function(n1,n2){if(n1==n2)
return false;if(n1.containsNode(n2))
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -