📄 comboboxitem.js
字号:
//> @attr ComboBoxItem.optionDataSource (DataSource | String : null : IRA) // @include PickList.optionDataSource //< //> @attr ComboBoxItem.pickListFields (Array : null : IRA) // @include PickList.pickListFields //< //> @method ComboBoxItem.fetchData() // @include PickList.fetchData() //< //> @attr ComboBoxItem.optionFilterContext (RPCRequest Properties : null : IRA) // @include PickList.optionFilterContext //< //> @attr ComboBoxItem.displayField (string : null : IRWA) // @include PickList.displayField // @visibility external //< //> @attr ComboBoxItem.valueField (string : null : IRW) // @include PickList.valueField // @visibility external //< //> @method ComboBoxItem.getDisplayFieldName() ([A]) // @include PickList.getDisplayFieldName() // @visibility external //< //> @method ComboBoxItem.getValueFieldName() // @include PickList.getValueFieldName() // @visibility external //< //> @attr ComboBoxItem.filterLocally // @include PickList.filterLocally // @visibility external //< //> @method ComboBoxItem.getSelectedRecord() // @include PickList.getSelectedRecord() // @visibility external //< //> @attr ComboBoxItem.pickListCriteria (Criteria : null : IRWA) // @include PickList.pickListCriteria // @visibility external //< //> @attr ComboBoxItem.showOptionsFromDataSource (boolean : null : IRWA) // @include PickList.showOptionsFromDataSource // @visibility external //< //> @attr ComboBoxItem.pickListProperties (object : null : IRA) // @include PickList.pickListProperties // @visibility external //< // Default pickList interface 'filtering' basically returns every record (this is the // desired behavior for select items). // For pickLists we want to show only the subset of options that matches the string // currently in the combo box text element. // Set filterDisplayValues to ensure that if we're working with client side options, // the filter criteria are recognized as the display values for the data not the raw values. filterDisplayValue:true, //> @attr ComboBoxItem.autoFetchData (boolean : false : [IRA]) // If this combo box retrieves its options from a <code>dataSource</code>, should options // be fetched from the server when the item is first written out, or should this fetch be // delayed until the user opens the pickList. // @visibility external // @see PickList.optionDataSource //< autoFetchData:false, //> @attr ComboBoxItem.filterWithValue (boolean : varies : [RA]) // Read-only property set by the ComboBoxItem to indicate whether we should use the // current typed-in value as part of the filter criteria returned by // +link{ComboBoxItem.getPickListFilterCriteria()}. You can check this flag in order to // mimic the ComboBoxItem's default behavior if you provide a custom implementation of // <code>getPickListFilterCriteria()</code>. // @visibility external //< //> @attr ComboBoxItem.alwaysFilterWithValue (boolean : false : [RA]) // If set to true, the default implementation of // +link{comboBoxItem.getPickListFilterCriteria()} will always add the current item's value // to the any specified pickListFilterCriteria, regardless of the current value of // +link{ComboBoxItem.filterWithValue}. // <P> // This was the default behavior for SmartClient version 5.6 and earlier. // @visibility internal //< //> @method ComboBoxItem.getPickListFilterCriteria() (A) // Returns filter criteria for options displayed for this item. // <P> // The criteria returned by this method are used to decide which options should appear in // the drop-down +link{PickList} shown by this ComboBox. // <P> // While the user is typing in a value, this method will return the typed-in value as part // of the criteria, so that only matching values are shown. Matching is determined by the // +link{comboBoxItem.textMatchStyle,textMatchStyle}. // <P> // If the user explicitly shows the down-down pickList, via either clicking on the drop // down icon or use the <i>Ctrl+Arrow Down</i> key combo, the typed in value is ignored for // filtering. // <P> // If included in the criteria, the typed in value will be included as a value for the // +link{ComboBoxItem.displayField,displayField} (or for the // +link{ComboBoxItem.valueField,valueField} if <code>this.displayField</code> is // unspecified). // <P> // Static criteria, specified via +link{comboBoxItem.pickListCriteria,pickListCriteria}, // will always be included. // <P> // If you are implementing your own <code>getPickListFilterCriteria()</code> the // <b>read-only</b> property +link{ComboBoxItem.filterWithValue,this.filterWithValue} can // be read to determine whether the ComboBox would ordinarily ignore the typed-in value for // filtering. Note that in addition to cases where the user explicitly shows the pickList, // <code>filterWithValue</code> will also be <code>true</code> during a call to // +link{ComboBoxItem.fetchData()} on a databound comboBox. // // @return (Criteria) criteria to be used for databound or local filtering // @visibility external //< getPickListFilterCriteria : function () { var crit = {}; if (this.alwaysFilterWithValue || this.filterWithValue) { var value = this.getDisplayValue(), fieldName = (this.getDisplayFieldName() || this.getValueFieldName()); crit[fieldName] = value; } // Assume that if pickListCriteria is specified it's a more fundamental filter that // should be applied in addition to filtering by the typed value. if (this.pickListCriteria) isc.addProperties(crit, this.pickListCriteria); return crit; }, //> @method comboBoxItem.getClientPickListData() // @include PickList.getClientPickListData() //< //> @method comboBoxItem.filterClientPickListData() // @include PickList.filterClientPickListData() //< //> @attr comboBoxItem.textMatchStyle (String : "startsWith" : IR) // @include PickList.textMatchStyle //< //> @attr comboBoxItem.showAllOptions (boolean : null : IR) // @include PickList.showAllOptions //< //> @method ComboBoxItem.dataArrived() // @include PickList.dataArrived() // @visibility external //< //> @attr comboBoxItem.separatorRows (Array of ListGridRecord : [{isSeparator:true}] : IR) // @include PickList.separatorRows //< // When the user blurs from the combo box item we want to ensure we hide the pickList. elementBlur : function () { this.Super("elementBlur", arguments); var pickList = this.pickList, EH = isc.EH, event = EH.lastEvent; //this.logWarn("eventType is: " + event.eventType + // " event.target: " + event.target + // " pickList.isAncestor: " + pickList.contains(event.target,true) + // ", activeElement: " + this.echoLeaf(document.activeElement)); // don't hide the pickList if .. if ( ( pickList && ( // the preceding event was a selectionChange event, which fires right after // mouseDown in the pickList, strangely triggered by some action we take in // Element._getElementFromSelection() // Special case because we can't look at event.target to determine if it was // a click on the pickList ( event.eventType == "selectionChange" && pickList.contains(isc.EH.mouseDownTarget()) ) || // it's a mouseDown/click on the pickList or one of it's subcomponents ( (event.eventType == EH.MOUSE_DOWN || event.eventType == EH.CLICK) && pickList.contains(event.target,true) ) ) ) || // ignore a delayed blur firing in IE when focus is still in the text input element (isc.Browser.isIE && this.getActiveElement() == this.getDataElement()) ) { return; } // ensure we don't show when // - delayed filter is kicked off // - asynchronous filter completes delete this._showOnFilter; delete this._showOnDelayedFilter; // bail if the pickList isn't showing if (!pickList || !pickList.isVisible()) return; // hide the pickList pickList.hide(); }, // Override showPicker to ensure we have focus, and show the pick list showPicker : function () { this.focusInItem(); this.filterWithValue = false; return this.showPickList(); }, // pickValue // This method is fired when a value is selected from the pick list. // update the value of this item, and fire the change handler. pickValue : function (value) { this.setElementValue(this.mapValueToDisplay(value)); // Hang a flag on the item so that we don't re-show the pick list this._valuePicked = true; // this is relying on the standard mapDisplayToValue() to convert from display value // back to data value for storage this.updateValue(); delete this._valuePicked; }, // override setValue map to update the list and update the displayed value if necessary. setValueMap : function () { this.Super("setValueMap", arguments); if (this.pickList) { if (this.pickList.isVisible()) this.pickList.hide(); // clear out the formItem property - ensures data / fields get re-set up when // the pickList is next shown. delete this.pickList.formItem // dont show the pickList if it's not already visible this.setUpPickList(this.pickList.isVisible()); } // The display-version of the value is likely to have changed, so update the element // value at this point. this.setElementValue(this.mapValueToDisplay(this.getValue())); }, // Override setValue and mapValueToDisplay to ensure that on an explicit setValue() to // a value that's not currently loaded in the pickList dataSet, we show the display value // rather than the underlying data value. setValue : function (newValue, a,b,c,d) { this._programmaticSetValue = true; this.invokeSuper(isc.ComboBoxItem, "setValue", newValue, a,b,c,d); delete this._programmaticSetValue; }, // override getDefaultValue to support defaultToFirstOption // override getDefaultValue to pick up the first option if defaultToFirstOption is true // getDefaultValue should not be able to return a value that is not included // in the valueMap for this select. getDefaultValue : function () { var dV; if (this.defaultToFirstOption) { dV = this.getFirstOptionValue(true, {target:this, methodName:"defaultToFirstReply"}); } if (!dV) dV = this.Super("getDefaultValue", arguments); return dV; }, defaultToFirstReply : function () { if (this.getValue() == null) this.setToDefaultValue(); }, // Override checkForDisplayFieldValue() // This is the method that, if we have a displayField specified, kicks off a fetch against // our optionDataSource to load the appropriate display value from the server. // In PickList based items we use the pickList data (if present) to map data to display // values. // Catch the case where checkForDisplayFieldValue is called when we are in the process of // fetching our pickList data from the server. // In this case we want to wait for the pickList data to be returned rather than kicking off // an additional fetch as our data value will usually be present in that pickList data. // When the pickList data returns we re-check this method. If the data is present, we're // done, otherwise we need to kick off another fetch as we didn't find our data value in // the pickList data array. This can happen if the pickList data is paged, for instance. _checkForDisplayFieldValue : function (newValue, delayed) { var inValueMap = (this._mapKey(newValue, true) != null); if (inValueMap) return; if (this._fetchingPickListData) { this._checkDisplayFieldValueOnFilterComplete = true; return; } this.invokeSuper(isc.ComboBoxItem, "_checkForDisplayFieldValue", newValue); }, // Map valueToDisplay and mapDisplayToValue need to pick up // the mapping between displayField and valueField, if there is one. // We implement this by overriding _mapKey() / mapDisplayToValue() to check for the value in // our pickList's dataSet, in addition to checking against any explicitly specified valueMap _mapKey : function (value, dontReturnKey, a,b,c,d) { var displayValue = this.invokeSuper(isc.ComboBoxItem, "_mapKey", value, true ,a,b,c,d); // _translateFieldValue part of the pickList interface if (displayValue == null && this.getDisplayFieldName() != null) displayValue = this._translateValueFieldValue(value, false); if (displayValue == null && !dontReturnKey) displayValue = value; return displayValue; }, mapDisplayToValue : function (value, a, b, c) { if (this.getDisplayFieldName() != null) { var displayValue; displayValue = this._translateValueFieldValue(value, true); if (displayValue != null) value = displayValue; } return this.invokeSuper(isc.ComboBoxItem, "mapDisplayToValue", value, a,b,c); }});isc.ComboBoxItem.registerStringMethods({ dataArrived:"startRow,endRow,data"});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -