⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treeview.js

📁 ajax 框价.是个好工具.javascript 矿家.可以用在任何平台.
💻 JS
📖 第 1 页 / 共 5 页
字号:
{if(!this.getDataModel())
return false;if(this._selectionMode=="row")
return this.getDataModel().getRowSelected(oItem.getRow());else return this.getDataModel().getCellSelected(oItem.getColumn(),oItem.getRow());};_p._selectItemRange=function(item1,item2,bDeselect){if(this._selectionMode=="row")
BiListSelectionModel.prototype._selectItemRange.call(this,item1,item2,bDeselect);else if(this._selectionMode=="cell")
{if(bDeselect)
this._deselectAll();var vm=this.getViewManager();var ri1=item1.getRow();var ci1=vm.getViewColumn(item1.getColumn());var ri2=item2.getRow();var ci2=vm.getViewColumn(item2.getColumn());var yMin=Math.min(ri1,ri2);var yMax=Math.max(ri1,ri2);var xMin=Math.min(ci1,ci2);var xMax=Math.max(ci1,ci2);var ci;for(var y=yMin;y<=yMax;y++)
{for(var x=xMin;x<=xMax;x++)
{ci=new BiTreeViewSelectionModelItem(vm.getModelColumn(x),y);this._selectedItems.add(ci);this.updateItemSelectionState(ci,true);}}}};_p._containsItem=function(oItem,oChild)
{return this.__containsItem(oItem.getRow(),oChild.getRow());};_p.__containsItem=function(nRow,nChild)
{if(nRow==nChild)
return true;var dm=this.getDataModel();var scc=dm.getShownChildrenCount(nRow);for(var i=nRow+1;i<nRow+scc+1;i++)
{if(this.__containsItem(i,nChild))
return true;}
return false;};_p._containsLeadItem=function(oItem)
{return this._leadItem&&this._containsItem(oItem,this._leadItem);};_p._containsAnchorItem=function(oItem)
{return this._anchorItem&&this._containsItem(oItem,this._anchorItem);};_p.containsSelectedNodes=function(oItem)
{var items=this._selectedItems.toArray();for(var i=0;i<items.length;i++)
{if(this._containsItem(oItem,items[i]))
return true;}
return false;};_p._collapseNode=function(oItem)
{var fireChange=false;if(this._selectionMode=="cell"&&oItem.getColumn()== -1)
oItem._column=0;if(this._containsLeadItem(oItem))
this.setLeadItem(oItem);if(this._containsAnchorItem(oItem))
this.setAnchorItem(oItem);if(this.containsSelectedNodes(oItem))
{var oldVal=this._getChangeValue();var oldFireChange=this._fireChange;this._fireChange=false;this._deselectAllDescendants(oItem);this.setItemSelected(oItem,true);this._fireChange=oldFireChange;if(this._fireChange&&this._hasChanged(oldVal))
fireChange=true;}
this.adjustSelection(oItem.getRow()+1,-this.getDataModel().getShownChildrenCount(oItem.getRow()));if(fireChange)
this._dispatchChange();};_p._expandNode=function(oItem)
{this.adjustSelection(oItem.getRow()+1,this.getDataModel().getShownChildrenCount(oItem.getRow()));};_p._deselectAllDescendants=function(oItem)
{var i2;var items=this._selectedItems.toArray();for(var i=0;i<items.length;i++)
{i2=items[i];if(oItem!=i2&&this._containsItem(oItem,i2))
{this.setItemSelected(i2,false);this._selectedItems.remove(i2);}}};_p.getRowSelected=function(y)
{return this.getDataModel().getRowSelected(y);};_p.setRowSelected=function(y,b)
{this.setItemSelected(new BiTreeViewSelectionModelItem(null,y),b);};_p.getCellSelected=function(x,y)
{return this.getDataModel().getCellSelected(x,y);};_p.setCellSelected=function(x,y,b)
{this.setItemSelected(new BiTreeViewSelectionModelItem(x,y),b);};_p.getRowIsLead=function(y)
{return this.getDataModel().getRowIsLead(y);};_p.getCellIsLead=function(x,y)
{return this.getDataModel().getCellIsLead(x,y);};_p.getCellIsAnchor=function(x,y)
{return this.getDataModel().getCellIsAnchor(x,y);};_p.setLeadItem=function(oItem)
{BiSelectionModel.prototype.setLeadItem.call(this,oItem);if(this._selectionMode=="row")
{if(this._leadItem&&!this.isEqual(oItem,this._leadItem))
{this.getDataModel()._setRowIsLead(this._leadItem.getRow(),false);}
if(oItem)
{this.getDataModel()._setRowIsLead(oItem.getRow(),true);}}
else {if(this._leadItem&&!this.isEqual(oItem,this._leadItem))
{this.getDataModel()._setCellIsLead(this._leadItem.getColumn(),this._leadItem.getRow(),false);this._leadItem=null;}
if(oItem)
{this.getDataModel()._setCellIsLead(oItem.getColumn(),oItem.getRow(),true);}}};_p.setAnchorItem=function(oItem)
{BiSelectionModel.prototype.setAnchorItem.call(this,oItem);if(this._selectionMode=="row")
{if(this._anchorItem&&!this.isEqual(oItem,this._anchorItem))
{this.getDataModel()._setRowIsAnchor(this._anchorItem.getRow(),false);}
if(oItem)
{this.getDataModel()._setRowIsAnchor(oItem.getRow(),true);}}
else {if(this._anchorItem&&!this.isEqual(oItem,this._anchorItem))
{this.getDataModel()._setCellIsAnchor(this._anchorItem.getColumn(),this._anchorItem.getRow(),false);this._anchorItem=null;}
if(oItem)
{this.getDataModel()._setCellIsAnchor(oItem.getColumn(),oItem.getRow(),true);}}};_p.adjustSelection=function(nRow,nCount)
{var reinsert=[];var item,itemRow,hc;var leadRow=this._leadItem?this._leadItem.getRow():-1;var anchorRow=this._anchorItem?this._anchorItem.getRow():-1;var hasSelected=false;var items=this._selectedItems.toArray();var i;for(i=0;i<items.length;i++)
{item=items[i];itemRow=item.getRow();if(itemRow>=nRow)
{this._selectedItems.remove(item);if(!(nCount<0&&itemRow<=nRow-nCount-1))
{item.setRow(itemRow+nCount);reinsert.push(item);continue;}}
hasSelected=true;}
for(i=0;i<reinsert.length;i++)
{item=reinsert[i];this._selectedItems.add(item);}
var rowCount=this.getDataModel().getRowCount();var col,row;if(leadRow>=rowCount||nCount<0&&leadRow>nRow||nCount>0&&leadRow>=nRow)
{col=this._leadItem.getColumn();this._leadItem=null;row=Math.min(rowCount-1,leadRow+nCount);if(row>=0)
this._leadItem=new BiTreeViewSelectionModelItem(col,row);}
if(anchorRow>=rowCount||nCount<0&&anchorRow>nRow||nCount>0&&anchorRow>=nRow)
{col=this._anchorItem.getColumn();this._anchorItem=null;row=Math.min(rowCount-1,anchorRow+nCount);if(row>=0)
this._anchorItem=new BiTreeViewSelectionModelItem(col,row);}
var stillAnySelected=this._selectedItems.toArray().length>0;if(hasSelected&&!stillAnySelected&&this._leadItem)
this._selectedItems.add(this._leadItem);};_p._syncAfterSort=function()
{var dm=this.getDataModel();var rowCount=dm.getRowCount();var columnCount=this.getViewManager().getColumnCount();this._selectedItems.removeAll();this._leadItem=null;this._anchorItem=null;var item,y;if(this._selectionMode=="row")
{for(y=0;y<rowCount;y++)
{if(dm.getRowSelected(y))
{item=new BiTreeViewSelectionModelItem(null,y);this._selectedItems.add(item);}
if(dm.getRowIsLead(y))
item=this._leadItem=item||new BiTreeViewSelectionModelItem(null,y);if(dm.getRowIsAnchor(y))
this._anchorItem=item||new BiTreeViewSelectionModelItem(null,y);}}
else {for(y=0;y<rowCount;y++)
{for(var x=0;x<columnCount;x++)
{if(dm.getCellSelected(x,y))
{item=new BiTreeViewSelectionModelItem(x,y);this._selectedItems.add(item);}
if(dm.getCellIsLead(x,y))
item=this._leadItem=item||new BiTreeViewSelectionModelItem(x,y);if(dm.getCellIsAnchor(x,y))
this._anchorItem=item||new BiTreeViewSelectionModelItem(x,y);}}}};_p._update=function(){var dm=this.getDataModel();if(!dm){return;}
var leadRow=this._leadItem?this._leadItem.getRow():-1;var leadCol=this._leadItem?this._leadItem.getColumn():null;var anchorRow=this._anchorItem?this._anchorItem.getRow():-1;var anchorCol=this._anchorItem?this._anchorItem.getColumn():null;var rowCount=dm.getRowCount();if(leadRow>=rowCount){this._leadItem=new BiTreeViewSelectionModelItem(leadCol,rowCount-1);}
if(anchorRow>=rowCount){this._anchorItem=new BiTreeViewSelectionModelItem(anchorCol,rowCount-1);}};function BiTreeViewSelectionModelItem(x,y)
{if(_biInPrototype)return;BiObject.call(this);this._row=y;this._column=x==null?-1:x;}
_p=_biExtend(BiTreeViewSelectionModelItem,BiObject,"BiTreeViewSelectionModelItem");BiTreeViewSelectionModelItem.prototype.getRow=function(){return this._row;};BiTreeViewSelectionModelItem.prototype.setRow=function(v){this._row=v;};_p.getLeft=function()
{return this._column;};_p.getTop=function()
{return this._row;};BiTreeViewSelectionModelItem.prototype.getColumn=function(){return this._column;};BiTreeViewSelectionModelItem.prototype.setColumn=function(v){this._column=v;};_p.equals=function(oItem2)
{return oItem2!=null&&this._row==oItem2.getRow()&&this._column==oItem2.getColumn();};function BiTreeViewViewManager(oTreeView)
{if(_biInPrototype)return;this._treeView=oTreeView;this._cache=null;};_p=_biExtend(BiTreeViewViewManager,BiObject,"BiTreeViewViewManager");BiTreeViewViewManager.prototype.getTreeView=function(){return this._treeView;};_p.setTreeView=function(tv)
{this._treeView=tv;};_p.getDataModel=function()
{return this._treeView.getDataModel();};_p._showGridLines=true;BiTreeViewViewManager.prototype.getShowGridLines=function(){return this._showGridLines;};BiTreeViewViewManager.prototype.setShowGridLines=function(v){this._showGridLines=v;};_p.resetCache=function()
{this._visibleColumnOrders=null;this._invertedColumnOrders=null;this._columnCache=null;this._cache=null;};_p.setScrollLeft=function(n)
{if(this._cache==null)
this._cache={};if(this._cache.scrollLeft!=n)
{this._cache.scrollLeft=n;var fvc=this._getFirstVisibleColumn(n);if(fvc==null)
{fvc=this._getLastVisibleColumn()||0;}
this._cache.firstVisibleColumn=fvc;this._cache.scrollLeft=this.getColumnLeft(this._cache.firstVisibleColumn);}};_p.setScrollTop=function(n)
{if(this._cache==null)
this._cache={};if(this._cache.scrollTop!=n)
{this._cache.scrollTop=n;this._cache.firstVisibleRow=this._getFirstVisibleRow(n);this._cache.scrollTop=this._cache.firstVisibleRow*this.getRowHeight();}};_p._ensureCache=function()
{if(this._cache==null)
this._cache={};this._cache.scrollLeft= -1;this._cache.scrollTop= -1;if(this._treeView&&this._treeView.getCreated())
{this.setScrollLeft(this._treeView.getScrollLeftExact());this.setScrollTop(this._treeView.getScrollTopExact());}
else {this.setScrollLeft(0);this.setScrollTop(0);}};_p.scrollColumnIntoView=function(x)
{if(this._cache==null)
this._ensureCache();var l=this.getShowRowHeaders()?this.getRowHeadersWidth():0;var g=this._treeView;var scrollLeft=this._cache.scrollLeft;var clientWidth=g.getClientWidth();var bounds=this.getColumnBounds(x);var rtl=this._getRightToLeft();if(!rtl)
{if(bounds.left-l<scrollLeft)
g.setScrollLeft(bounds.left-l);else if(bounds.left+bounds.width>scrollLeft+clientWidth)
g.setScrollLeft(bounds.left+bounds.width-clientWidth);}
else {var sr2;if(bounds.left-l<=scrollLeft)
sr2=bounds.left-l;else if(bounds.left+bounds.width>=scrollLeft+clientWidth)
sr2=bounds.left+bounds.width-clientWidth;g.setScrollLeft(this._treeView._gridBodyElement.scrollWidth-sr2-clientWidth);}};_p.scrollRowIntoView=function(y)
{if(this._cache==null)
this._ensureCache();var g=this._treeView;var t=this.getShowHeaders()?this.getHeadersHeight():0;var scrollTop=this._cache.scrollTop;var clientHeight=g.getClientHeight();var bounds=this.getRowBounds(y);if(bounds.top<=scrollTop)
g.setScrollTop(bounds.top-t);else if(bounds.top+bounds.height>scrollTop+clientHeight)
g.setScrollTop(Math.ceil((bounds.top+bounds.height-clientHeight)/this.getRowHeight())*this.getRowHeight());};_p.scrollCellIntoView=function(x,y)
{this.scrollRowIntoView(y);this.scrollColumnIntoView(x);};_p.scrollSubtreeIntoView=function(y)
{if(this._cache==null)
this._ensureCache();var bounds=this.getRowBounds(y);var g=this._treeView;var t=bounds.top;var st=this._cache.scrollTop;var ch=g.getClientHeight();var fh=this.getShowHeaders()?this.getHeadersHeight():0;var lastY=y+this.getDataModel().getShownChildrenCount(y);var lastBounds=this.getRowBounds(lastY);var lastTop=lastBounds.top;var lastHeight=lastBounds.height;var h=lastTop+lastHeight-t;if(h>ch||t<=st)
g.setScrollTop(t-fh);else if(t+h>st+ch)
g.setScrollTop(Math.ceil((t+h-ch)/this.getRowHeight())*this.getRowHeight());this._ensureCache();};_p.getColumnCount=function()
{if(this._columnCache&&"count"in this._columnCache)
return this._columnCache.count;var dm=this.getDataModel();if(!this._columnCache)
this._columnCache={};if(dm)
{var l=dm.getColumnCount();var sum=0;for(var mx=0;mx<l;mx++)
{if(this.getColumnVisible(mx))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -