Skip to Content
0

SAP Design Studio - Select the first value of a Dropdown

Jun 28, 2017 at 02:22 PM

188

avatar image

Hello dear community,

I'm trying to select the first value in a Dropdown box, but I can't find a solution to fix this problem.

I have a dropdown box with multiple values and need to select the text of the first value.

Does somebody know a solution for that ? It doesn't have to be a dropdown box at all cost. I just need something where I can sort alphabetically and then select the first / second / third value of it.

Thanks for the help in advance!

10 |10000 characters needed characters left characters exceeded

Hi Vu,

Can you provide some more context about the use case you are trying to implement? It sounds like you just want an internal mechanism for sorting a list as an array and then iterate through that list to access its elements one by one, rather than specifically needing a UI component like a dropdown where the items are selected via user interaction. Is that right? As Tammy has pointed out, your data source will be relevant here too.

Regards,

Mustafa.

0

Hi Mustafa,

yes, you are right.

I want to sort a list of saved bookmarks alphabetically. After that I want to display the text of the first 3 elements in 3 different text boxes.

I don't know if I'm using a BEx Query as a datasource. I'm using a relational database schema of Oracle, so I think it's an universe.

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Mustafa Bensan Jun 29, 2017 at 07:07 AM
1

Hi Vu,

In Design Studio 1.6 there is no option to explicitly sort the list of bookmarks when you use getAllBookmarkInfos(). I can't remember off the top of my head if getAllBookmarkInfos() returns the list in alphabetical order or not. You could try that first and iterate through the first three elements to set the texts. If that doesn't work then the cleanest approach would be to use the SDK Community Collection Utility Component to sort the bookmarks and retrieve the top 3, with code as follows:

var myBookmarks = Bookmark.getAllBookmarks();

myBookmarks.forEach(function(bookmarkInfo, index) {
  COLLECTION_1.addItem(bookmarkInfo.id, bookmarkInfo.text,index);
});

COLLECTION_1.sortByLabel();

var bookmarkArray = COLLECTION_1.getAsKeyLabelValueArray();

var bookmark1 = bookmarkArray[0];
var bookmark2 = bookmarkArray[1];
var bookmark3 = bookmarkArray[2];

TEXT_1.setText(bookmark1.label);
TEXT_2.setText(bookmark2.label);
TEXT_3.setText(bookmark3.label);

In the above example I have assumed you are using Standard Bookmarks. You can adapt it for Fragment or Portable Fragment Bookmarks if needed.

Regards,

Mustafa.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Mustafa,

thanks for your help again!

You are always the person who finds the perfect solution for my problems!

Regards,

Vu

0

Happy to be of help, Vu.

0
Tammy Powlas
Jun 28, 2017 at 02:37 PM
0

Hi Vu - I assume you are using a BEx query as a data source?

In the dropdown you could set the member display settings at the application start-up and in the binding

DROPDOWN_1.setItems(DS_1.getMemberList("ZPROJ", MemberPresentation.INTERNAL_KEY, MemberDisplay.TEXT_KEY, 5, "ALL"));

But I am not sure if that is what you are looking for.


1vu.jpg (10.7 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Tammy,

thanks for the answer, but unfortunately that wasn't what I was looking for.

Regards,

Vu.

0