There are a few things to consider here
- There's an automatic "pre fetch" for Selectitems/ComboBoxItems by default, meaning they will fetch optionDataSource results before you show the pickList. You can turn this off via "autoFetchData:false"
- By default items bound to the same optionDataSource will share their data sets to avoid multiple fetches. You can turn this off via 'cachePickListResults:false'
- Once a fetch has occurred and the pickList is populated, hiding and then re-showing the pickList will not issue another fetch. You can explicitly call various APIs including "fetchData()" on a selectItem to force the cached data set to be dropped and a new fetch issued. So to force a new fetch each time the pickList is shown, you could override 'showPicker'.
Here's a sample demonstrating this with 4 items (2 CBIs, 2 SIs) bound to the same datasource, with the same criteria. Each time you show any of the pickLists you should see a fetch occur.
(In some cases you can get 2 fetches, this is due to a drawing/resizing behavior whereby a window of 75 rows is retrieved from the server, and then a second request is issued for the subsequent 75 rows. It should be safe to ignore)
Regards
Isomorphic Software
Code:
<isomorphic:loadDS ID="supplyItem"/> // Form 1 - one SelectItem, one ComboBoxItem // Form 2 - one SelectItem, one ComboBoxItem // Bound to the same data Sources / same criteria // We want to force a new fetch // - for each item when the PL is first shown // - for each time the PL is shown via a show-picker click within an item isc.defineClass("SelectItemAlwaysFetch", "SelectItem").addProperties({ // Avoid sharing results with other items cachePickListResults:false, // Don't fetch until the PL is first shown autoFetchData:false, // Invalidate any cache/ Force a new fetch on every "showPicker" showPicker : function () { if (this.pickList && this.pickList.data.lengthIsKnown()) this.fetchData(); return this.Super("showPicker", arguments); } }); isc.defineClass("ComboBoxItemAlwaysFetch", "ComboBoxItem").addProperties({ // Avoid sharing results with other items cachePickListResults:false, // Don't fetch until the PL is first shown autoFetchData:false, // Invalidate any cache/ Force a new fetch on every "showPicker" showPicker : function () { if (this.pickList && this.pickList.data.lengthIsKnown()) this.fetchData(); return this.Super("showPicker", arguments); } }); isc.VStack.create({ autoDraw:true, membersMargin:10, members:[ isc.DynamicForm.create({ ID:"form1", items:[ {editorType:"SelectItemAlwaysFetch", name:"item1", optionDataSource:supplyItem, valueField:"itemName", pickListCriteria:{ _constructor:"AdvancedCriteria", fieldName:"itemID", operator:"lessThan", value: 4000 } }, {editorType:"ComboBoxItemAlwaysFetch", name:"item2", optionDataSource:supplyItem, valueField:"itemName", pickListCriteria:{ _constructor:"AdvancedCriteria", fieldName:"itemID", operator:"lessThan", value: 4000 } } ] }), isc.DynamicForm.create({ ID:"form2", items:[ {editorType:"SelectItemAlwaysFetch", name:"item1", optionDataSource:supplyItem, valueField:"itemName", pickListCriteria:{ _constructor:"AdvancedCriteria", fieldName:"itemID", operator:"lessThan", value: 4000 } }, {editorType:"ComboBoxItemAlwaysFetch", name:"item2", optionDataSource:supplyItem, valueField:"itemName", pickListCriteria:{ _constructor:"AdvancedCriteria", fieldName:"itemID", operator:"lessThan", value: 4000 } } ] }), isc.DynamicForm.create({ ID:"serverFetchLog", items:[ {editorType:"StaticTextItem", name:"fetchCount", value:0} ] }) ] }); serverFetchLog.observe( supplyItem, "transformRequest", "observer.setValue('fetchCount', (observer.getValue('fetchCount') + 1))" );
Edit:
Note: If you're working in SmartGWT you'd want to use addPickerIconClickHandler() to call fetchData() [and there'd be no need to call "Super", of course]
Leave a comment: