cancel
Showing results for 
Search instead for 
Did you mean: 

Check drop down status

former_member643798
Participant
0 Kudos

Hi,

Ive MVC UI5 project with controller and fragment,in the fragment I've Drop down which is getting the data from

the controller,most of the time the service are providing data to the ddl but in some cases not.

in case that the drop down is not getting data from the controller I want to display text no customers found instead the drop down

i.e. not to draw the drop down at all,how can I do that ?

Example will be very helpful since Im very new to UI5

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

former_member182862
Active Contributor
0 Kudos
former_member643798
Participant
0 Kudos

HI Dennis ,

Thanks but I want to avoid drawing the control in the screen if there is no value,and I want to avoid any css manipulation

Thanks again!

former_member182862
Active Contributor
0 Kudos

Hi Joerg

You can extend the control in this manner

// extend the sap.m.Select control
sap.m.Select.extend('LeanSelect', {
  renderer: function(r, c) {
    if (c.getItems() && c.getItems().length > 0) {
      sap.m.SelectRenderer.render(r, c);
    }
  }
});

JS Bin - Collaborative JavaScript Debugging

former_member643798
Participant
0 Kudos

HI Dennis,

Do you mean like this ?

http://jsbin.com/siyujepupo/1/edit?css,js,output

If yes how can I put some text like no fruit found in case the drop down is empty

2. can you please explain in short what does the renderer function in extend ?

3. does the same logic will be used to extend the DDL not from M lib ?

Thanks

Joerg

former_member182862
Active Contributor
0 Kudos

Hi Joerg

Here is what you need

JS Bin - Collaborative JavaScript Debugging

Basically, we extend the sap.m.Select control to not render the dropdown box but the text if there are no items.

You can do the same for other controls.

Thanks

-D

former_member643798
Participant
0 Kudos

Thanks a lot Dennis!

It will be great if you can add some description what does the renderer does

and what I should do if I want to extend control in UI5. from the regular docu its not easy to understand that...

former_member182862
Active Contributor
0 Kudos

You're welcome. We are here to help.

Every control needs a renderer. a Renderer is just a function that create the DOM object.

you can read more here

SAPUI5 SDK - Demo Kit

Thanks

-D

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Use the getItems() method to see if there are any items.

if (oSelect.getItems()){

     // show dropdown

} else {

     // remove the dropdown and show the text

}

kind regards,

RW