cancel
Showing results for 
Search instead for 
Did you mean: 

update dropdown box after Ajax call

Former Member
0 Kudos
236

Hi,

I created a dropdown control in my application as below.

var dropdown_c0c0 = new com.sap.xmii.ui.UIElementDropdownM({

dataStatic:"false",

dataDynamic :"true",

keyValueList :"",

queryPath:"Test/test.XQry",

keyColumn:"wc",

valueColumn:"wc",

defaultValue:"",

colSpan :"2",

rowSpan :"1",

topPosition :"1",

leftPosition :"7",

controlVisible :"true",

controlEnabled :"true",

textSize:"12",

controlId: 2,

onSelect :"",

onInitialize :""});

form_c0c0.add(dropdown_c0c0);

on event,  I passed parameters to the query Test/test.XQry  which is attached to the dropdown and executed the query using Ajax. I want  to populate the result of the query in the dropdown after Ajax call.

$.ajax({

                    url: '/XMII/Illuminator?QueryTemplate=Test/test.XQry&Content-Type=text/json',

                    type: 'POST',

                     data:{'Param.1':plant, 'Param.2':sfc},

                    success: function(sdata)

                    {                     

                         var oResult = sdata.Rowsets.Rowset[0].Row;

                        var abc = [];

                        abc.push(oResult[0].wc);

                      

                        var oModel = new sap.ui.model.json.JSONModel();

                        oModel.setData(abc);

                        dropdown_c0c0.setModel(oModel);

                     

                    }

})

But still the dropdown is not updated. Any help will be appreciated.

Regards,

Naga.

Accepted Solutions (0)

Answers (2)

Answers (2)

junwu
Active Contributor
0 Kudos

did you get the data in the ajax call?

gurunadh_kumar
Explorer
0 Kudos

Hi Jun,

Sorry for the delay.

Yes,I got the response after the ajax call.

I have added oModel.refresh(true) at the end of the code as below.But still it doesn't work.There is no error but the dropdown is not updated/refreshed.

$.ajax({

                    url: '/XMII/Illuminator?QueryTemplate=Test/test.XQry&Content-Type=text/json',

                    type: 'POST',

                     data:{'Param.1':plant, 'Param.2':sfc},

                    success: function(sdata)

                    {                    

                         var oResult = sdata.Rowsets.Rowset[0].Row;

                        var abc = [];

                        abc.push(oResult[0].wc);

                     

                        var oModel = new sap.ui.model.json.JSONModel();

                        oModel.setData(abc);

                        dropdown_c0c0.setModel(oModel);

                         oModel.refresh(true);

                    

                    }

})

Regards,

Naga.

Ankit_Maskara
Advisor
Advisor
0 Kudos

Hello,

Did you check in SAPUI5 Diagostics(CTRL+ALT+SHIFT+S) about the binding of control ?

What is shown there ?

BR.

junwu
Active Contributor
0 Kudos

i am asking did you get the data in the ajax call?

junwu
Active Contributor
0 Kudos

oModel.refresh(true)


check if it helps.

Former Member
0 Kudos

Hi Jun,

It didn't work

Regards,

Naga.