Hi experts!
I have a form with a comboBox as follow:
new sap.ui.layout.form.FormElement(this.createId('cboImpostos'),{ label : '{i18n>lancamento.crud.cboImposto.title}', fields : [ new sap.m.ComboBox(this.createId('impostos'), { value: '{/limp/codigoTipoImposto}', items : [ new sap.ui.core.Item({ key : 'ICMS', text : '{i18n>lancamento.crud.cboImposto.ICMS}' }), new sap.ui.core.Item({ key : 'IPI', text : '{i18n>lancamento.crud.cboImposto.IPI}' }), new sap.ui.core.Item({ key : 'INSS', text : '{i18n>lancamento.crud.cboImposto.INSS}' }), new sap.ui.core.Item({ key : 'ISS', text : '{i18n>lancamento.crud.cboImposto.ISS}' }), new sap.ui.core.Item({ key : 'OUTROS', text : '{i18n>lancamento.crud.cboImposto.Outros}' }) ], editable: '{= ${page-state>/edit} === true}', }).attachSelectionChange(function(oEvt) { oController.handleImpostoValueChange(oEvt) }) ] }),
and I'm setting the model on my controller like this:
onInit: function() { this.getRouter().getRoute("lancamentoImpostoCRUD").attachPatternMatched(this._onObjectMatched, this); } _onObjectMatched : function (oEvent) { this._bindView(oEvent.getParameter("arguments").lancamentoID, this.getView().byId('formLancamentoCRUD')) }, _bindView: function (lancamentoID, form) { sessionStorage['lancamentoID'] = lancamentoID if(lancamentoID !== -1) { var params = { lancamentoID: lancamentoID } var url = Config.getUrlFor('hana:lancamentoImposto.find', params) var model = new sap.ui.model.json.JSONModel() model.loadData(url) form.setModel(model) } },
But after that when I try to recover the value of the selected item from the comboBox, it's empty!!!
var cboImposto = this.getView().byId('impostos') var selectedItem = cboImposto.getSelectedKey() console.log("Teste: " + selectedItem)
The log is an empty text. What am I doing wrong? Thanks in advance!!