cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 at runtime or dynamic

HFumey
Participant
0 Kudos
266

Hi to All

I have been looking at UI5 for a while now, going through examples and slowly getting them to work. I saw a couple of them with the word "dynamic" in the description but I failed to find what of the code gets generated during runtime. For example in a table the columns which should be displayed are all written out in code with an "addColumn". This means that I need to know before hand what the table is going to look like. There are cases (e.g. customer configurable table in SAP back end) where this will not be known while creating the view in UI5. Sooo... how is it possible to handle something like this with SAPUI5?

It is not obvious and maybe I am just missing something. Sometimes I think UI5 is a step backward compared to WebDynpro (which of course has other issues).

I would much appreciate any pointers or links which could help explain how SAPUI5 can handle runtime/dynamic generation.

Thanks

Harry

Accepted Solutions (0)

Answers (3)

Answers (3)

HFumey
Participant
0 Kudos

Thanks for your responses to my question. I appreciate the time you have given me.

Regards,

Harry

Former Member
0 Kudos

Hi Harry,

I've never been a big fan of dynamic generation of content in Web Dynpro although I have built it on occasion (in WD Java at least.)  However, I don't really see SAPUI5 as being any different in terms of how you would approach it, in fact I'd say the approach would generally be the same regardless of the UI technology.

If you can get a table of dynamic columns from your backend SAP system, you can write some relatively simplistic JavaScript loops to create the columns and add them to a table.  You could also use binding methods as highlighted by Jason above, which may or may not be easier depending upon the use case.  I noticed earlier on posted a question over on StackOverflow along similar lines, where he has some code that might give you a starter for 10?

For me, I'd typically approach it in a similar way to many of the other *sp languages, such as JSP, BSP, etc.  So you can create your empty table, then add the columns via either binding or looping, then add your data rows via binding.

This is exactly the same way as I'd do it with Web Dynpro.

Does that make any sense?!

Cheers,

Gareth.

Qualiture
Active Contributor
0 Kudos

Hi Harry,

To give credit where credit is due, it were the answers provided that ultimately solved my quest for dynamic table creation/binding with

And to my eyes, it looks even cleaner than a Web Dynpro Java equivalent approach

jmoors
Active Contributor
0 Kudos

One possible approach is to use the function factory to create controls from model data.

See the example in the documentation.

https://sapui5.hana.ondemand.com/sdk/#docs/guide/BindingAggregations.html

Many thanks,

Jason