From: <pru...@us...> - 2012-03-20 23:40:37
|
Revision: 6117 http://jaffa.svn.sourceforge.net/jaffa/?rev=6117&view=rev Author: prudhvireddy Date: 2012-03-20 23:40:31 +0000 (Tue, 20 Mar 2012) Log Message: ----------- Back merged 'allowNumberOnly' functionality from trunk Modified Paths: -------------- branches/JAFFA_5_12_RELEASE/JaffaRIA/source/html/js/extjs/jaffa/finder/FinderComboBox.js Modified: branches/JAFFA_5_12_RELEASE/JaffaRIA/source/html/js/extjs/jaffa/finder/FinderComboBox.js =================================================================== --- branches/JAFFA_5_12_RELEASE/JaffaRIA/source/html/js/extjs/jaffa/finder/FinderComboBox.js 2012-03-20 22:47:53 UTC (rev 6116) +++ branches/JAFFA_5_12_RELEASE/JaffaRIA/source/html/js/extjs/jaffa/finder/FinderComboBox.js 2012-03-20 23:40:31 UTC (rev 6117) @@ -60,6 +60,12 @@ invalidateMultipleRecordsFoundText: 'Multiple records found that match the value in this field', /** + * @cfg {String} invalidNumberText The error text to use when marking a field invalid when it must contain a numeric value. + * (defaults to "The value in this field is invalid") + */ + invalidNumberText: 'The value for this field must be a number', + + /** * @cfg {boolean} validateStoreOnly true will force validation only against values in the store. * Only use this if you are forcing the store to be loaded in all cases. Otherwise typing a value directly and * then leaving the field will always report the value as invalid @@ -90,6 +96,11 @@ * Defaults to Ext.emptyFn. */ getStaticBaseParams : Ext.emptyFn, + + /** + * @cfg {boolean} allowNumberOnly false - If true will validate that the value is a number. + */ + allowNumberOnly : false, /* @cfg {Record}. Reference to the selected record. Do not access this property directly. Use getSelectedRecord() method to access this value. @@ -235,6 +246,14 @@ this.validateOnBlur = false; this.validationEvent = false; + var psf = this.primarySearchField || (this.meta && this.meta.finder && this.meta.finder.primarySearchField) || this.valueField; + if (this.meta.fields[psf]){ + var searchFieldMeta = this.meta.fields[psf]; + if (searchFieldMeta && (searchFieldMeta.type=='int'||searchFieldMeta.type=='float')){ + this.allowNumberOnly = true; + } + } + this.on('autoselect', function(combo, items) { if (items && items.length==1) { this.fireEvent('select', combo, items[0], Number.NaN); // the index value does not exist because items may not be in the combo store. @@ -426,6 +445,13 @@ // Retrieves records that match the current data. AutoSelects a record if only one is returned. // The field is marked as invalid if no record or multiple records are retrieved. doAutoselect: function(combo, exactQuery) { + + if (!Ext.isNumber(Number(combo.getValue())) && this.allowNumberOnly){ + this.markInvalid(this.invalidNumberText); + this.isValueValid = false; + return; + } + if (! combo.store) return; this.selectedRecord = null; //Resetting before auto selecting a record; var value = combo.getValue(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |