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

📄 list2.js

📁 ajax 框价.是个好工具.javascript 矿家.可以用在任何平台.
💻 JS
📖 第 1 页 / 共 2 页
字号:
/*	Class: List2	Description: The same thing as BiList.*/function List2(oData){	BiTreeView.call(this);	this.setItems(oData);	// Event Listeners	this.addEventListener("dblclick", this._itemMouseAction);	this.addEventListener("keypress", this._onKeyPress, this);	this.addEventListener("keypress", this._itemKeyAction);	this.getSelectionModel().addEventListener("change", function(e){this._changeListener();}, this);	// UI Adjustments	this.getViewManager().getHighlightSortColumn = this.getViewManager().getShowRowHeaders = this.getViewManager().getShowGridLines = this.getViewManager().getShowHeaders = function(){return false;};	this.getViewManager().getColumnWidth = function(x){		if(!this.getTreeView().getCreated()) return 0;		return Math.abs(this.getTreeView().getClientWidth());	};	this.getViewManager().getIndentColumn = function(){return -1;};	this.getDataModel().getHasIcon = function(x, y){return x == 0;};	this.setOverflowX("hidden");	// Icon path	this._iconUri = application.getPath() + "/images/file.png";}_p = List2.prototype = new BiTreeView;_p._className = "List2";_p._showIcon = false;_p._iconUri = null;_p._dataSource = null;_p._allowInlineFind = false;_p._dataTextField = null;_p._dataUserValueField = null;_p._dataPageSize = null;_p._dataPageCount = 1;_p._currentDataPage = 0;_p._accumulatedKeys = "";_p._syncWithCommmand = BiList.prototype._syncWithCommmand;_p.setAllowInlineFind = BiList.prototype.setAllowInlineFind;_p.getAllowInlineFind = BiList.prototype.getAllowInlineFind;_p.getDataSource = BiList.prototype.getDataSource;_p.setDataSource = BiList.prototype.setDataSource;_p.getUserValue = BiList.prototype.getUserValue;_p.getUserValues = BiList.prototype.getUserValues;_p.setValue = _p.setUserValue;_p.getValue = _p.getUserValue;_p.getValues = _p.getUserValues;_p.getDataTextField = BiList.prototype.getDataTextField;_p.setDataTextField = BiList.prototype.setDataTextField;_p.getDataUserValueField = BiList.prototype.getDataUserValueField;_p.setDataUserValueField = BiList.prototype.setDataUserValueField;_p.getDataPageSize = BiList.prototype.getDataPageSize;_p.getDataPageCount = BiList.prototype.getDataPageCount;_p.getCurrentDataPage = BiList.prototype.getCurrentDataPage_p.setDataPageSize = BiList.prototype.setDataPageSize;_p.setCurrentDataPage = BiList.prototype.setCurrentDataPage;_p.dataBind = BiList.prototype.dataBind;_p.findString = BiList.prototype.findString;_p.findStringExact = BiList.prototype.findStringExact;_p.findUserValueExact = BiList.prototype.findUserValueExact;_p.findValueExact = _p.findUserValueExact;// Hide/show the icon beside a list item_p.setShowIcon = function(bBool){	this._showIcon = bBool;	this.update();}// Returns whether the icon is showing_p.getShowIcon = function(){	return this._showIcon;}// Sets the URI for the Icon (Icon path)_p.setIconUri = function(oUri){	this._iconUri = oUri;	this.update();}// Returns the URI of the icon_p.getIconUri = function(){	return this._iconUri;}// Sets the uservalue for the list// Param: uservalue of a List2Item// Return: void_p.setUserValue = function(oUserValue){	var s = this.getSelectedItems();	for(var i = 0; i < s.length; i++)		s[i].setSelected(false);	var c = this.findUserValueExact(oUserValue);	this._userValue = c.getUserValue();	c.setSelected(true);	this.update();}_p._setUserValue = function(oUserValue){	this._userValue = oUserValue;}// Creates a new List2Item from BiDataRow// Return: List2Item// Param: DataRow_p.createItemFromDataRow = function(oRow){	return new List2Item(oRow.getValueByName(this._dataTextField), oRow.getValueByName(this._dataUserValueField));};// Sets/unsets the multiple selection option.// Return: void// Param: boolean_p.setMultipleSelection = function(bBool){	this.getSelectionModel().setMultipleSelection(bBool);	var c = this.getSelectedItems();	for(var i = 1; i < c.length; i++)		c[i].setSelected(false);	this.update();}// Returns if multiple selection is allowed// Return: boolean// Param: None_p.getMultipleSelection = function(){	return this.getSelectionModel().getMultipleSelection();}// Returns the selected items in the list// Return: List2Item[]// Param: None_p.getSelectedItems = function(){	if(this.getItemCount() == 0)		return [];	var a = this.getSelectionModel().getSelectedItems();	for(var i = 0; i < a.length; i++)		a[i] = this.getItemAt(a[i].getRow());	return a;}// Returns the first selected item// Return: List2Item// Param: None_p.getSelectedItem = function(){	var s = this.getSelectionModel().getSelectedItems()[0];	if(s)		return this.getItemAt(s.getRow());	return null;}// Selects all items in the list_p.selectAll = _p.selectAllItems = function(){	this.getSelectionModel().selectAll();}// Selects all items in the list_p.deselectAll = _p.deselectAllItems = function(){	this.getSelectionModel().deselectAll();}// Sets the selected item for this list. The item must be in the list// Param: List2Item, boolean// Return: void_p.setItemSelected = function(oItem, bSelected){	if(this.getItemAt(oItem._index) == oItem)	{		oItem._selected = bSelected;		this.getSelectionModel().setRowSelected(oItem._index, bSelected);		if(bSelected)			this.scrollItemIntoView(oItem);	}}_p.contains = function(oObj){	if(oObj instanceof List2Item)		for(var i = 0; i < this.getItemCount(); i++)			if(this.getItemAt(i) == oObj)				return true;	else		for(var i = 0; i < this.getItemCount(); i++)			if(this.getItemAt(i).getText() == oObj)				return true;	return false;}// Returns whether a particular item is selected_p.getItemSelected = function(oItem){	if(this.getItemAt(oItem._index) == oItem)		return this.getDataModel()._rows[oItem._index].selected;	throw new Error("Item not part of collection!");}// Sorts the List2// Return: void// Param://		x - The index from where to sort//		bAscending - Sort in ascending/desending order. true for ascending, false for descending_p.sort = function(x, bAscending){	this.getDataModel().sort(x, bAscending);}// Sets the items for this list.// Clears the current items.// Param: List2Item[]// Return: void_p.setItems = function(oData){	if(!oData || oData.length == 0)		oData = [new List2Item()];	var a = new Array(oData.length);	for(var i = 0; i < a.length; i++)	{		oData[i]._index = i;		oData[i]._parent = this;		a[i] = [oData[i]];	}	if(this.getDataModel())		this.getDataModel().dispose();	this.setDataModel(new List2DataModel(a, this));	this.removeItemAt(0);}// Appends a List2Item[] to the end of a List2// Param: List2Item[]// Return: void_p.addItems = function(oItems){	var l = this.getItemCount();	var n;	for(var i = 0; i < oItems.length; i++)	{		n = l + i;		oItems[i]._index = n;		oItems[i]._parent = this;		this._set(n, oItems[i]);	}	this.update();}// Appends a List2Item to the end of a List2// Param: List2Item// Return: void_p.addItem = _p.add = function(oItem){	if(oItem instanceof BiListItem)	{		var l = this.getItemCount();		this.getSelectionModel().adjustSelection(l, 1);		this._set(l, oItem);		this.update();	}	else	{		BiTreeView.prototype.add.apply(this, arguments);	}}// Inserts an item at a particular position in the list// Param://		i - Index [0 >= i < listSize - 1]//		oItem - List2Item// Return: void_p.insertItemAt = _p.insertAt = function(i, oItem){	oItem._index = i;	oItem._parent = this;	this.getDataModel().insertRowAt([oItem], i);	for(var j = i + 1; j < this.getItemCount(); j++)		this.getItemAt(j)._index = j;	this.updateContentSize();}// Removes a List2Item from a specified index// Param: Number// Return: void_p.removeItemAt = _p.removeAt = function(i){	this.getSelectionModel().adjustSelection(i, -1);	this.getItemAt(i).dispose();	this.getDataModel().removeRowAt(i);	for(var j = i; j < this.getItemCount(); j++)		this.getItemAt(j)._index--;}// Removes a List2Item from the list// Param: List2Item// Return: void_p.removeItem = _p.remove = function(oItem){	if(oItem instanceof BiListItem)	{		this.removeItemAt(this.indexOfItem(oItem));	}	else	{		BiTreeView.prototype.remove.apply(this, arguments);	}}// Removes all Items from the list// Param: None// Return: void_p.removeAllItems = _p.removeAll = function(){	while(this.getItemCount() > 0)		this.removeItemAt(0);}// Sets the item at a particular index to be oItem// Param: Number, List2Item// Return: void_p.setItemAt = _p.set = function(i, oItem){	this._set(i, oItem);	this.updateRow(i);}// Returns the List2Item at a particular index// Param: Number// Return: List2Item_p.getItemAt = _p.get = function(i){	return this.getDataModel().getDataAt(i)[0];}// Returns the first item in the list_p.getFirstChild = _p.getFirst = function(){	return this.getItemAt(0);}// Returns the last item in the list_p.getLastChild = _p.getLast = function(){	if(this.getItemCount() > 0)		return this.getItemAt(this.getItemCount() - 1);

⌨️ 快捷键说明

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