javascript - providing a blank option in the combobox sapui5 -
i trying populate dropdownbox in sapui5 json
new sap.ui.commons.dropdownbox(this.createid('inpexpensetype'), { selectedkey: '{expensetype/id}', editable: '{/caneditpayment}', required: "{/caneditpayment}", displaysecondaryvalues: true, items: { path: 'parameters>/benefits', template: new sap.ui.core.listitem(this.createid('liexpensetype'), { key: '{parameters>id}', text: '{parameters>name}', additionaltext: '{parameters>code}' }) }, layoutdata: new sap.ui.layout.griddata({span: 'l6 m6 s6'}) }).attachchange(oms.app.modelutils.handlelistitemchange)
now based on condition eg. if(status==='approved'), wish show 1 option in dropdownbox. used below filter done.
if(state==='approved'){ //this option wish display in dropdownbox. afilters.push(new sap.ui.model.filter("id", sap.ui.model.filteroperator.eq, "33")); } odropdownbox.binditems('parameters>/benefits', otemplate, null, afilters);
now problem single option getting defaulted in dropdownbox onchange event not triggered.
i tried default blank item below
if(state==='approved'){ var oitem = new sap.ui.core.listitem({ key: 'dummy', text: '', additionaltext: '' }); odropdownbox.insertitem(oitem,0); odropdownbox.setselectedkey('dummy'); }
but not make difference , see single option populated default.
how can solve this? there clean way manipulate json list?
no need add new item.
use firechange after bind items have no issues.
odropdownbox.binditems('parameters>/benefits', otemplate, null, afilters); odropdownbox.firechange();
Comments
Post a Comment