Hello Isomorphic,
I've encountered following problem. When SelectItem is first shown bound to custom DataSource which returns data synchronously (i.e. call "processResponse" from within "transformRequest", see attached TestCase source), it shows "Loading..." until pick list is first shown. The reason is that PickList class "filterDataBoundPickList" method calls "this.pickList.filterData" and then unconditionally sets this._fetchingPickListData to true without verifying that "filterComplete" method was already called. Please see following test case. All 3 of created form items are expected to behave the same. But second form item, which is bound to synchronous DataSource remains in "Loading..." state unless pick list is opened:
<html>
<!-- =================== Smart Client Loading ======================================= -->
<SCRIPT>window.isomorphicDir = "/SmartClient/"</SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_History.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_Core.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_Foundation.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_Containers.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_Grids.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_Forms.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_DataBinding.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/skins/Enterprise/load_skin.js"></SCRIPT>
<script>
isc.setAutoDraw(false);
</script>
<body onload="initialize()">
<script>
isc.ClassFactory.defineClass("MyDataSource", "RestDataSource")
isc.MyDataSource.addProperties({
dataProtocol: "clientCustom",
dataFormat: "json",
asyncMode: false,
//--------------------------------------------------------------------------------------------------------
init: function() {
this.Super("init", arguments)
this.fields = [
{ name: "theValue", type: "string" },
{ name: "theText", type: "string" }
]
this.clientOnly = true
},
//--------------------------------------------------------------------------------------------------------
transformRequest: function(dsRequest) {
var dsResponse = {
clientContext: dsRequest.clientContext
}
dsRequest.dataFormat = "json"
dsResponse.status = 0
dsResponse.data = [
{ theValue: "Val1", theText: "Text1" },
{ theValue: "Val2", theText: "Text2" },
{ theValue: "Val3", theText: "Text3" },
]
if (this.asyncMode) {
var me = this
setTimeout(function() {
me.processResponse(dsRequest.requestId, dsResponse);
}, 0);
} else {
this.processResponse(dsRequest.requestId, dsResponse)
}
},
//--------------------------------------------------------------------------------------------------------
getDataProtocol: function(dsRequest) {
return "clientCustom"
}
});
</script>
<script>
function initialize() {
var form = isc.DynamicForm.create({
items: [
{ editorType: "SelectItem", title: "With ValueMap", multiple: true, value: ["Val1", "Val3"],
valueMap: { Val1: "Text1", Val2: "Text2", Val3: "Text3" }
},
{ editorType: "SelectItem", title: "With Sync DataSource", multiple: true, value: ["Val1", "Val3"],
optionDataSource: isc.MyDataSource.create({}), valueField: "theValue", displayField: "theText"
},
{ editorType: "SelectItem", title: "With Async DataSource", multiple: true, value: ["Val1", "Val3"],
optionDataSource: isc.MyDataSource.create({asyncMode: true}), valueField: "theValue", displayField: "theText"
}
]
});
form.show();
}
</script>
</body>
I've encountered following problem. When SelectItem is first shown bound to custom DataSource which returns data synchronously (i.e. call "processResponse" from within "transformRequest", see attached TestCase source), it shows "Loading..." until pick list is first shown. The reason is that PickList class "filterDataBoundPickList" method calls "this.pickList.filterData" and then unconditionally sets this._fetchingPickListData to true without verifying that "filterComplete" method was already called. Please see following test case. All 3 of created form items are expected to behave the same. But second form item, which is bound to synchronous DataSource remains in "Loading..." state unless pick list is opened:
<html>
<!-- =================== Smart Client Loading ======================================= -->
<SCRIPT>window.isomorphicDir = "/SmartClient/"</SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_History.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_Core.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_Foundation.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_Containers.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_Grids.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_Forms.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/system/modules/ISC_DataBinding.js"></SCRIPT>
<SCRIPT SRC="/SmartClient/skins/Enterprise/load_skin.js"></SCRIPT>
<script>
isc.setAutoDraw(false);
</script>
<body onload="initialize()">
<script>
isc.ClassFactory.defineClass("MyDataSource", "RestDataSource")
isc.MyDataSource.addProperties({
dataProtocol: "clientCustom",
dataFormat: "json",
asyncMode: false,
//--------------------------------------------------------------------------------------------------------
init: function() {
this.Super("init", arguments)
this.fields = [
{ name: "theValue", type: "string" },
{ name: "theText", type: "string" }
]
this.clientOnly = true
},
//--------------------------------------------------------------------------------------------------------
transformRequest: function(dsRequest) {
var dsResponse = {
clientContext: dsRequest.clientContext
}
dsRequest.dataFormat = "json"
dsResponse.status = 0
dsResponse.data = [
{ theValue: "Val1", theText: "Text1" },
{ theValue: "Val2", theText: "Text2" },
{ theValue: "Val3", theText: "Text3" },
]
if (this.asyncMode) {
var me = this
setTimeout(function() {
me.processResponse(dsRequest.requestId, dsResponse);
}, 0);
} else {
this.processResponse(dsRequest.requestId, dsResponse)
}
},
//--------------------------------------------------------------------------------------------------------
getDataProtocol: function(dsRequest) {
return "clientCustom"
}
});
</script>
<script>
function initialize() {
var form = isc.DynamicForm.create({
items: [
{ editorType: "SelectItem", title: "With ValueMap", multiple: true, value: ["Val1", "Val3"],
valueMap: { Val1: "Text1", Val2: "Text2", Val3: "Text3" }
},
{ editorType: "SelectItem", title: "With Sync DataSource", multiple: true, value: ["Val1", "Val3"],
optionDataSource: isc.MyDataSource.create({}), valueField: "theValue", displayField: "theText"
},
{ editorType: "SelectItem", title: "With Async DataSource", multiple: true, value: ["Val1", "Val3"],
optionDataSource: isc.MyDataSource.create({asyncMode: true}), valueField: "theValue", displayField: "theText"
}
]
});
form.show();
}
</script>
</body>
Comment