From: <cos...@us...> - 2011-05-23 18:41:51
|
Revision: 5291 http://jaffa.svn.sourceforge.net/jaffa/?rev=5291&view=rev Author: cosbor11 Date: 2011-05-23 18:41:45 +0000 (Mon, 23 May 2011) Log Message: ----------- added a listener to handle populating targetFields when the user selects a record Modified Paths: -------------- trunk/JaffaRIA/source/html/js/extjs/jaffa/finder/FinderComboGrid.js Modified: trunk/JaffaRIA/source/html/js/extjs/jaffa/finder/FinderComboGrid.js =================================================================== --- trunk/JaffaRIA/source/html/js/extjs/jaffa/finder/FinderComboGrid.js 2011-05-23 18:39:56 UTC (rev 5290) +++ trunk/JaffaRIA/source/html/js/extjs/jaffa/finder/FinderComboGrid.js 2011-05-23 18:41:45 UTC (rev 5291) @@ -25,6 +25,13 @@ * * Defaults to Ext.emptyFn. */ + staticBaseParams : undefined, + + /** + * @cfg targetFields a collection of name value pairs that are used to populate other fields in the form. + * if the targetFields = ['siteCode=siteCode'], the field in the same form that has a mapping of siteCode will be populated with value of the siteCodeField in the selected record + */ + targetFields: [], getStaticBaseParams : Ext.emptyFn, primarySearchField : undefined, initComponent: function() { @@ -64,8 +71,27 @@ // if (items && items.length > 1) // combo.renderGrid(); // }); + + this.on('select', this.populateTargetFields); }, + //a selection handler that is used to populate other fields on the form + populateTargetFields: function(cbo, rec){ + if(!cbo.targetFields){return;} + var ownerPanel = cbo.ownerCt; + for(var i = 0; i < cbo.targetFields.length; i++){ + var rule = cbo.targetFields[0]; + var targetPanelFieldMapping = rule.split('=')[0]; + var targetRecFieldName = rule.split('=')[1]; + if(targetPanelFieldMapping && targetRecFieldName){ + var targetPanelField = ownerPanel.find('mapping', targetPanelFieldMapping)[0] || ownerPanel.find('mapping', 'flexBean.' + targetPanelFieldMapping)[0]; + if(targetPanelField && rec){ + targetPanelField.setValue(rec.get(targetRecFieldName)); + } + } + } + }, + // This method is called by the doQuery. This will hide the list in lookup-mode or when more records exist expand: function() { if (this.popupAlways || (this.store.reader.jsonData && (this.store.reader.jsonData.moreRecordsExist || this.store.reader.jsonData.totalRecords > this.store.reader.jsonData[this.meta.finder.root].length))) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |