📄 picklist.js
字号:
return (record != null) }, // -- Data bound filtering -- // filterComplete - callback fired when the data to be displayed has been filtered. // (Will be called for both databound and non-databound lists) filterComplete : function (response, data, request) { this._fetchingPickListData = false; var list = this.pickList; if (!list || list.destroyed) return; var data = list.getData(); if (data.getLength() == 0 && list.isVisible()) { // no matches, so hide the dropdown, place focus in the form item itself list.hide(); if (hasFocus) this.focusInItem(); } else { // if we set the flag to show the list after the filter, show it now! var hasFocus = list.hasFocus || (list.body && list.body.hasFocus); if (this._showOnFilter) this._showPickList(); // If the list is already showing, call placePickList to ensure it resizes to // accomodate content if required. else if (list.isVisible() && list.isDrawn()) this.placePickList(); delete this._showOnFilter; } // Always select the default item at this point // (Don't want to select the default item BEFORE the list is shown as the selection // will get wiped out when the data is changed). if (list.isVisible()) this.selectDefaultItem(); // _checkDisplayFieldValueOnFilterComplete // This flag is set up by the ComboBox / SelectItem class as part of checkDisplayFieldValue // if a pickList filter operation is running while that method is called. // In this case we need to recheck now the pickList data has loaded. // If the pickList data loaded a display value for this fields value, we're done, // otherwise we need to perform another fetch if (this._checkDisplayFieldValueOnFilterComplete) { delete this._checkDisplayFieldValueOnFilterComplete; this._checkForDisplayFieldValue(this._value); } // helper - if we're currently showing a data value and we just loaded the associated // display value, display it. this._updateDisplayValueForNewData(); // If a callback was passed in when the filter was intialized, fire it now, passing in // the resultSet as a single parameter var callback = (request && request.clientContext ? request.clientContext._callback : null); if (callback) this.fireCallback(callback, "item,dsResponse", [this, response]); }, // If this item has a databound pickList, and a 'displayField', // If the value has been set to some data value, which doesn't correspond // to a row loaded in the pickList, and we haven't mapped to a display value // (EG fetchMissingValues is false, etc), if the data does subsequently get loaded in // the pickList, we want to update the element value to show the display value. // We do this in response to new data arriving for the pickList (a filter operation completes) _updateDisplayValueForNewData : function () { if (this.isDrawn() && this.getValueFieldName() != null && this._getOptionsFromDataSource()) { var currentVal; if (!this._itemValueIsDirty()) currentVal = this.getValue(); else { if (this.isA("SelectItem")) currentVal = this._localValue; else currentVal = this.mapDisplayToValue(this.getElementValue()); } var displayVal = this.mapValueToDisplay(currentVal); if (this._displayValue != displayVal) this.setElementValue(displayVal); } }, // This will only be called on a databound pickList filterDataBoundPickList : function (requestProperties, dropCache) { var criteria = this.getPickListFilterCriteria(), context = { // NOTE: 2007.3.5 server does not actually support "startsWith" match style, // treats it as "substring" textMatchStyle:this.textMatchStyle, showPrompt:false }; // this.optionFilterContext - an entry point to add properties to the operation context, such // as the name of a defined operation. if (this.optionFilterContext != null) isc.addProperties(context, this.optionFilterContext); // Additional properties to be applied to the request can be passed as a parameter. // This code path is used for the userVisible 'fetchData()' api if (requestProperties != null) { isc.addProperties(context, requestProperties); } var synchronousFilter = false; if (this.pickList.data && isc.isA.ResultSet(this.pickList.data)) { if (dropCache) { // invalidateCache doesn't have a way to apply a callback. // Instead call '_invalidateCache' to drop the cache (without re-fetching) // Then continue with filterData() as normal this.pickList.data._invalidateCache(); // Use 'willFetchData' to see if a fetch is required } else if (!this.pickList.data.willFetchData(criteria,this.textMatchStyle)) { synchronousFilter = true; } } this.pickList.filterData(criteria, {target:this, methodName:"filterComplete"}, context); if (synchronousFilter) this.filterComplete(); else this._fetchingPickListData = true; }, //> @method PickList.dataArrived() // If this item is showing a dataBound pickList, this notification method will be fired // when new data arrives from the server. // @param startRow (number) index of first row returned by the server // @param endRow (number) index of last row returned by the server // @param data (ResultSet) pointer this pickList's data // @visibility external //< dataArrived : function (startRow, endRow, data) { }, // -- Client side filtering -- //> @attr PickList.textMatchStyle (boolean : "startsWith" : IR) // When applying filter criteria to pickList data, what type of matching to use. Legal // values are "substring" (value contains user input) or "startsWith" (value starts with // user input. Both matches are case insensitive. // <P> // For a databound pickList (+link{optionDataSource} set), <code>textMatchStyle</code> is // sent to the server as +link{dsRequest.textMatchStyle}. // <P> // For a non-databound pickList, <code>textMatchStyle</code> is applied by // +link{filterClientPickListData()}. // // @visibility external //< textMatchStyle : "startsWith", //>@attr PickList.showAllOptions (boolean : null : IR) // If true, even non-matching options will be shown, with configurable // +link{separatorRows,separator rows} in between. Not valid for // +link{optionDataSource,databound pickLists}. // // @visibility external //< //>@attr PickList.separatorRows (Array of ListGridRecord : [{isSeparator:true}] : IR) // Array of records to show between matching and non-matching rows in the PickList. // <P> // Not valid for +link{optionDataSource,databound pickLists}. // // @visibility external //< //>@method PickList.filterClientPickListData() // Returns the data to display in the pick list. // <P> // The default implementation applies the criteria returned by // +link{PickList.getPickListFilterCriteria()} to the data returned by // +link{PickList.getClientPickListData()}. A record passes the filter if it has a // matching value for all fields in the criteria object. Matching is performed according // to +link{textMatchStyle}. // <P> // If +link{PickList.showAllOptions} is set, all values are shown, with matching values // shown below a +link{PickList.separatorRows,separator}. // // @return (Array of ListGridRecord) array of record objects to display in the pickList // // @visibility external //< _$substring : "substring", separatorRows : [{ isSeparator:true }], filterClientPickListData : function () { var data = this.getClientPickListData(), criteria = this.getPickListFilterCriteria(); if (criteria == null || isc.isA.emptyObject(criteria)) return data; var matches = [], nonMatches; if (this.showAllOptions) nonMatches = this.separatorRows.duplicate(); var validCriterion = false; for (var fieldName in criteria) { var searchString = criteria[fieldName]; if (!searchString || isc.isA.emptyString(searchString)) continue; validCriterion = true; // Do a raw conversion to strings if passed non string values if (!isc.isA.String(searchString)) searchString += isc.emptyString; searchString = searchString.toLowerCase(); var dataLength = data.getLength(), valueFieldName = this.getValueFieldName(); for (var i = 0; i < dataLength; i++) { var possibleMatch = data[i][fieldName]; // for the valueField, run the record values through mapValueToDisplay() so // they match what the users sees. XXX running through the valueMap is // appropriate here, but a formatter that returns HTML may screw this up if (this.filterDisplayValue && fieldName == valueFieldName) { possibleMatch = this.mapValueToDisplay(possibleMatch); } // For now we'll do a stringwise comparison regardless of the data type of // the possible match if (!isc.isA.String(possibleMatch)) possibleMatch += ""; possibleMatch = possibleMatch.toLowerCase(); // Remove any mismatches from the list of options if ((this.textMatchStyle == this._$substring && !possibleMatch.contains(searchString)) || (this.textMatchStyle != this._$substring && // assume startsWith !isc.startsWith(possibleMatch, searchString))) { if (this.showAllOptions) nonMatches.add(data[i]); } else { matches.add(data[i]); } } } if (!validCriterion) matches = data.duplicate(); if (this.showAllOptions && nonMatches.length > 1) matches.addList(nonMatches); //this.logWarn("returning: " + this.echoAll(matches)); return matches; }, // -------------------------------------------------------------------------------------- // PickList appearance // -------------------------------------------------------------------------------------- // Position / sizing // getPickListPosition; getPickListPosition : function () { return [this.getPageLeft(), this.getPageTop() + this.getHeight()]; }, // getPickListHeight - returns the desired height of the pickList based on the number of // records and the specified pickListHeight getPickListHeight : function () { var maxHeight = this.pickListHeight, pickList = this.pickList, numRows = pickList.getTotalRows(), cellHeight = pickList.cellHeight, headerHeight = (pickList.showHeader ? pickList.headerHeight : 0), recordsHeight = numRows * cellHeight, requiredHeight = recordsHeight + headerHeight + pickList.getVBorderPad(); return Math.min(requiredHeight, maxHeight); }, _sizePickList : function (minWidth, height, vscrollOn) { var pickList = this.pickList, newWidth = minWidth; // to determine whether to autoSize, check fixedFieldWidths, since if we're showing a // header we never autoSize since headers currently can't automatically size to match // column sizes. if (pickList.fixedFieldWidths || pickList.body == null || !pickList.body.isDrawn()) { //this.logWarn("not autoSizing pickList: fieldWidths: " + pickList.fixedFieldWidths + // " body: " + pickList.body); pickList.resizeTo(newWidth, height); return; } // Autosize list to fit widest option. var scrollbarSize = (vscrollOn ? pickList.body.getScrollbarSize() : 0); pickList.body.setOverflow(isc.Canvas.HIDDEN); // avoid space being left fo
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -