📄 list2.js
字号:
return null;}// Returns the index of a List2Item in the list// Param: List2Item// Return: Number_p.indexOfItem = _p.indexOf = function(oItem){ for(var i = 0; i < this.getItemCount(); i++) if(this.getItemAt(i) == oItem) return i;}// Returns the number of List2Items in the list// Param: None// Return: Number_p.getItemCount = _p.getCount = function(){ var dm = this.getDataModel(); if(dm) return dm.getRowCount(); return 0;}// Returns an array of List2Items specified by nStart and nEnd// If you specify left index, right index is optional// If you do not specify any indices, the whole list is returned// Param:// nStart: left index (optional)// nEnd: right index (optional)// Return: List2Item[]_p.getItems = function(nStart, nEnd){ if(!nStart) nStart = 0; if(!nEnd) nEnd = this.getItemCount(); if(nStart < 0 || nEnd < 0 || nStart > nEnd) throw new Error("Invalid bounds!"); var s = new Array(nEnd - nStart); for(var i = nStart; i <= s.length - 1; i++) s[i] = this.getItemAt(i); return s;}// Same as getItems_p.getChildren = function(){ return this.getItems();}_p.scrollItemIntoView = function(oItem){ if(this.getItemAt(oItem._index) == oItem) this.getViewManager().scrollRowIntoView(oItem._index);}_p.disposeAllItems = function(){ for(var i = 0; i < this.getItemCount(); i++) this._dataModel.getDataAt(i)[0].dispose();}// Method associated with cleaning up a List2// Do not use list once disposed._p.dispose = function(){ if(this._dataSource) this._dataSource.dispose(); this.disposeAllItems(); this._dataSource = null; this._dataTextField = null; this._dataUserValueField = null; this._userValue = null; this._iconUri = null; this._showIcon = null; this._dataPageSize = 0; this._dataPageCount = 0; this._currentDataPage = 0; BiTreeView.prototype.dispose.call(this);}_p._set = function(n, oItem){ try { this.getDataModel()._rows[n].data[0].dispose(); } catch(ex) {}; if(n >= this.getItemCount()) this.getDataModel()._rows.push({}); else this.getDataModel()._rows[n] = {}; oItem._index = n; oItem._parent = this; this.getDataModel()._rows[n].data = [oItem];}_p.getSelectedIndex = function(){ return this._selectedIndex;}_p._changeListener = function(){ var o = this.getSelectedItem(); if(o) { this._setUserValue(o.getUserValue()); this._selectedIndex = o.getIndex(); if(this._command) this._command.setUserValue(this.getUserValue()); this.dispatchEvent(new BiEvent("change")); } else this._selectedIndex = -1;}_p._itemMouseAction = function(e){ var r = this.getViewManager().getRowAt(e.getOffsetY()); try { this.getItemAt(r).dispatchEvent(new BiEvent("action")); this.dispatchEvent(new BiEvent("action")); } catch(ex) {};}_p._itemKeyAction = function(e){ if(e.getKeyCode() == BiKeyboardEvent.ENTER) { var s = this.getSelectedItems(); for(var i = 0; i < s.length; i++) s[i].dispatchEvent(new BiEvent("action")); this.dispatchEvent(new BiEvent("action")); }}_p._afterSort = function(){ for(var i = 0; i < this.getItemCount(); i++) this.getItemAt(i)._index = i; this.getSelectionModel()._syncAfterSort(); this.update();}_p._findItem = function(sText, nStartIndex){ if(nStartIndex < 0) nStartIndex = 0; var items = this.getItems(); for(var i = nStartIndex; i < items.length; i++) if(items[i].matchesStringBeginning(sText)) return items[i]; for(var i = 0; i < items.length; i++) if(items[i].matchesStringBeginning(sText)) return items[i]; return null;};_p._onKeyPress = function(e){ if(!this._allowInlineFind || new Date - this._lastKeyPress < 10) return; if(new Date - this._lastKeyPress > 1000) this._accumulatedKeys = ""; this._accumulatedKeys += String.fromCharCode(e.getKeyCode()); var item = this._findItem(this._accumulatedKeys, this._selectedIndex); if(item) { document.title = item.getText(); item.setSelected(true); } this._lastKeyPress = (new Date).valueOf(); e.preventDefault();};_p._populateWithDataSource = function(){ this.removeAllItems(); BiList.prototype._populateWithDataSource.call(this);}/* Class: List2DataModel Description: This class specifies settings for List2 to follow.*/function List2DataModel(oData, oTreeView){ BiGridDataModel.call(this, oData); this._treeview = oTreeView;}_p = List2DataModel.prototype = new BiGridDataModel;_p._className = "List2DataModel";// Returns if a column can be sorted._p.getCanSortColumn = function(x){ return false;};// Returns the number of columns associated with the list_p.getColumnCount = function(){ return 1;}_p.getHasIcon = function(){ return this._treeview.getShowIcon();}// Returns the URI for the icon_p.getIcon = function(){ return this._treeview.getIconUri();}// Sorts the data in an ascending/descending order from a specified index[x]_p.sort = function(x, bAscending){ BiTreeViewDataModel.prototype.sort.call(this, x, bAscending); this._treeview._afterSort();}// Method associated with cleaning up a datamodel// Do not use once disposed._p.dispose = function(){ if(this._disposed) return; BiGridDataModel.prototype.dispose.call(this); this._treeview = null;}/* Class: List2Item Description: This class contains the data for each row of a List2. It extends BiEventTarget.*/function List2Item(oText, oData){ BiEventTarget.call(this); this._text = oText; this._userValue = oData || "";}_p = List2Item.prototype = new BiEventTarget;_p._className = "List2Item";_p._userValue = null;_p._text = null;_p._parent = null;_p._index = -1;// Sets the selection state of List2Item_p.setSelected = function(bSelected){ if(this._parent) this._parent.setItemSelected(this, true);}// Returns if this item is selected_p.getSelected = function(){ return this._parent ? this._parent.getItemSelected(this) : false;}// Returns the item's parent_p.getParent = function(){ return this._parent;}// Returns the text caption of this item// This text is displayed in the list_p.getText = function(){ return String(this._text);}// Sets the text for this item_p.setText = function(sText){ this._text = sText;}// Sets the userdata for this item.// User data is the value associated with this item_p.setUserValue = function(oData){ this._userValue = oData;}// Returns the user value_p.getUserValue = function(){ return this._userValue;}// Returns the index of this item in a List2 only if the item has a parent_p.getIndex = function(){ if(this._parent) return this._index; return -1;}// Returns the toString() representation of this object.// This method is automatically used by BiTreeView to determine the label for an item_p.toString = function(){ return this._text;}// Method that cleans up data associated with this item.// Do not use once disposed._p.dispose = function(){ if(this._disposed) return; this._text = null; this._userValue = null; this._parent = null; this._index = -1; BiEventTarget.prototype.dispose.call(this);}// Same as BiListItem_p.getValue = _p.getUserValue;_p.setValue = _p.setUserValue;_p.matchesStringExact = BiListItem.prototype.matchesStringExact;_p.matchesString = BiListItem.prototype.matchesString;_p.matchesStringBeginning = function(sText){ var str = String(sText).toLowerCase(); var txt = this.getText().toLowerCase(); if(str == txt) return true; else if(str.length > txt.length) return false; else return txt.substring(0, str.length) == str;};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -