Version: v11.0p_2017-01-16/LGPL
[Problem]:
When I specify a displayField and a foreignDisplayField on a SelectItem with an OptionDataSource, it should first try to find the displayValue from the current record using DisplayField (according to the docs), but it actually triggers a fetchMissingValues call on the optionDataSource. If you add fetchMissingValues:false, the id is shown instead of the displayValue.
[Why is this a problem]:
An extra fetch is triggered for the missing displayvalue, but this value is already in the current (form) record.
Update: added some additional problems and test cases in the example
[Example]:
[Problem]:
When I specify a displayField and a foreignDisplayField on a SelectItem with an OptionDataSource, it should first try to find the displayValue from the current record using DisplayField (according to the docs), but it actually triggers a fetchMissingValues call on the optionDataSource. If you add fetchMissingValues:false, the id is shown instead of the displayValue.
[Why is this a problem]:
An extra fetch is triggered for the missing displayvalue, but this value is already in the current (form) record.
Update: added some additional problems and test cases in the example
[Example]:
Code:
isc.DataSource.create({
ID:"options",
clientOnly:true,
fields:[{name:"id",primaryKey:true,type:'integer'},{name:"name",type:'text'}],
cacheData:[{id:1,name:'First'},{id:2,name:'Second'},{id:3,name:'Third'}]
})
isc.DataSource.create({
ID:"tests",
clientOnly:true,
fields:[{name:"id",primaryKey:true,type:'integer'},{name:"expectedResult",type:'text'},{name:"option",type:"integer"},{name:'optionValue',hidden:true,type:'text'}]
})
isc.ValuesManager.create({
ID:'vmgr',
dataSource:'tests'
})
isc.DynamicForm.create({
ID:'editor',
valuesManager:'vmgr',
fields:[{name:'id'},{name:'expectedResult',width:600},{name:'option',optionDataSource:"options",valueField:'id',foreignDisplayField:'name',displayField:'optionValue'}]
})
vmgr.editRecord({
id:1,
expectedResult:'Field "option" should display: "First (Not displayed, but should be shown)" instead of "First"',
option:1,
optionValue:'First (Not displayed, but should be shown)'
})
isc.ValuesManager.create({
ID:'vmgr2',
dataSource:'tests'
})
isc.DynamicForm.create({
ID:'editor2',
fields:[{name:'id'},{name:'expectedResult',width:600},{name:'option',optionDataSource:"options",valueField:'id',foreignDisplayField:'name',fetchMissingValues:false,autoFetchData:false}],
valuesManager:'vmgr2'
})
vmgr2.editRecord({
id:2,
expectedResult:'To display id value (fetchMissingValues=false && autoFetchData=false)',
option:2,
optionValue:'Second (Not displayed, but should be shown)'
})
isc.ValuesManager.create({
ID:'vmgr3',
dataSource:'tests'
})
isc.DynamicForm.create({
ID:'editor3',
fields:[{name:'id'},{name:'expectedResult',width:600},{name:'option',displayField:'optionValue'}],
valuesManager:'vmgr3'
})
vmgr3.editRecord({
id:3,
expectedResult:'Field "option" should display: "Third (Not displayed, but should be shown)" instead of "3"',
option:3,
optionValue:'Third (Not displayed, but should be shown)'
})
isc.VLayout.create({
members:[editor,editor2,editor3]
})
Comment