on 10-05-2020 6:04 AM
I'm triying to figure out whay my data is not displayed in my selectDialog
this is my view:
<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core">
<SelectDialog
id="patronDialogo"
noDataText="Sin patrones"
title="Seleccione un patr/u00F4"
search=".onSearch"
confirm=".onDialogClose"
cancel=".onDialogClose"
items="{patrones>/}">
<StandardListItem
title="{patrones>DescripcionCont}"
description="{patrones>TipoContenedor}"
icon="sap-icon://shipping-status"
iconDensityAware="false"
iconInset="false"
type="Active" />
</SelectDialog>
</core:FragmentDefinition>
and this is my controller:
var url = "/sap/opu/odata/sap/ZCLMMVSR_ODATA_CARGA_CONTENT_SRV";
var oDataModel = new sap.ui.model.odata.ODataModel(url, true);
var mensaje = "";
var oView = this.getView();
var jsonData = new JSONModel();
sap.ui.core.BusyIndicator.show(0);
if ( !this._oDialogPatron ) {
this._oDialogPatron = sap.ui.xmlfragment("z_vsr_ihu_cargarContenedor.view.DialogPatron", this);
}
try {
oDataModel.read("/patronFotosSet", {
success: function(oData, response) {
sap.ui.core.BusyIndicator.hide();
jsonData.setData(oData.results);
oView.setModel(jsonData, "patrones");
},
error: function(oError) {
sap.ui.core.BusyIndicator.hide();
}
});
} catch (e){
sap.ui.core.BusyIndicator.hide();
return reject(mensaje = "ERROR en llamado OData")
}
jQuery.sap.syncStyleClass("sapUiSizeCompact", this.getView(), this._oDialogPatron);
this.getView().addDependent(this._oDialogPatron);
this._oDialogPatron.open();
So my select dialog it's displayed but whithout data:
Hi,
I think the problem here is due to the async nature of your oData call. While you instantiate the dialog and open it, the async oData call is triggered to load the data and to set the model. So you have to make sure, that the model data is loaded first before you instatiate the dialog.
I tried it the following way and it works perfectly:
Dialog code:
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core">
<SelectDialog id="selectDialog" noDataText="No data"
title="Test select"
search=".onSearch"
confirm=".onDialogClose"
cancel=".onDialogClose"
items="{patrones>/}">
<StandardListItem
title="{patrones>DescripcionCont}"
description="{patrones>TipoContenedor}"
icon="sap-icon://shipping-status"
iconDensityAware="false"
iconInset="false" type="Active"/>
</SelectDialog>
</core:FragmentDefinition>
Controller code:
fnOnSelectDialogShow: function () {
var jsonModel = new JSONModel();
var oModel = this.getView().getModel();
oModel.read("/patronFotosSet", {
success: function (oData) {
jsonModel.setData(oData.results);
this.getView().setModel(jsonModel, "patrones");
// Load Dialog
if (!this._oDialog) {
Fragment.load({
name: "z_vsr_ihu_cargarContenedor.view.DialogPatron",
controller: this
}).then(function (oDialog) {
this._oDialog = oDialog;
this.getView().addDependent(this._oDialog);
this._oDialog.open();
}.bind(this);
} else {
this._oDialog.open();
}.bind(this)
},
error: function (oError) {
MessageToast.show("Error occured");
}
});
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.