i try bind data combobox, don't solved. can see model (modeldata) , data in model.
could tell me, if structure inside of result (ex_labor) correct is?
<combobox items="{modeldata}" selecteditem="selecteditem" selectedkey="keyselectedkey" selecteditemid="idselecteditemid" id="idcomboboxlabor" placeholder="datum" textalign="initial" textdirection="inherit" maxwidth="100%" change="onchangelabordatum" selectionchange="onselectionchangelabordatum"> <items> <core:item key="{modeldata>patientid}" text="{modeldata>/patientid}"/> </items> </combobox>
i put ajax request in init function.
controller: jquery.ajax({ url: aurl, method: 'get', datatype: 'json', contenttype: "application/json", success: function(data, textstatus, jqxhr) {
// create json model instance var omodelcombobox = new sap.ui.model.json.jsonmodel(); /* // set data model result: {"ex_labor":{"0":{"patientid":3161,"datum":"2014-12-08t23:00:00.000z"},"1":{ */ omodelcombobox.setdata(data); // set model core sap.ui.getcore().setmodel(omodelcombobox, "modeldata"); var adata = omodelcombobox.getproperty("/ex_labor"); var omodel1 = new sap.ui.model.json.jsonmodel(); // omodel1.attachrequestcompleted(function() { omodel1.setdata({ modeldata: adata }); console.error(omodel1); console.error(adata); // }); }
would helpful, if 1 of me.
you need correct binding of combobox items aggregation:
items="{modeldata>/ex_labor}
also ex_labor should array.
plus need correct binding of item text property (as mentioned @qualiture):
text="{modeldata>patientid}"
in general should rethink naming: "modeldata" bad name not clear model contains data, not clear kind of data. furthermore recommended use:
this.getview().setmodel(model, name)
instead of storing in core.
Comments
Post a Comment