cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI refresh view file example: MyList.view.xml

0 Kudos

The question may seem strange. I have an application which allows the users to choose the columns appearing on a form/list. I prefer sending the forms as an xml view. To me is easier to understand/debug for a program team. A servlet creates my views - thus my views are not static. I know there are advantages and disadvantages to every approach. Personally, I find a lot of js code a bit of a mess.

So the example is:

User goes to a screen MyList.view.xml.

The user decides to create a new calculated field in the view.

Field: Outstanding Amount

Value: amount - #sum(obligationPayments.![oblPaymentAmount]) (SPEL syntax.)

Without reloading the entire app I would like to force the front end to reload MyList.view.xml. Is that possible?


Accepted Solutions (1)

Accepted Solutions (1)

jamie_cawley
Advisor
Advisor
0 Kudos

Using javascript in a controller you would need to get a reference to the form or list and then use the appropriate function to add whatever you are trying to add. An example

https://stackoverflow.com/questions/46953184/adding-new-column-to-the-existing-table-on-ui5

Regards,

Jamie

Answers (2)

Answers (2)

0 Kudos

In short - I decided to use fragments to load Tables. My back end is cross-tab aware. It is also aware of custom columns. The backend can handle dynamic table fragments easily. A cross tab is data dependant and thus a view would never work.

I agree that javascript is good for very dynamic columns. But the minus is that it takes a lot of js code and I do not find it simple for a tech support person to work with. A fragment can be degugged by clicking F12- Network connections. The Smart Filter Bar is an example of a nice js solution, but for some Entities it does not work. (Blank screen the odata connections are fine.) Finding the issue with it is not easy.

So, I decided for dynamic fragments that change depending on the inputs.

I understand that the answers are correct for the question.

CristianBabei
Contributor
0 Kudos

Don't think you can do it, maybe if somehow you load your XML with AJAX but this is not how UI5 is thought to be used.

If you want to build the page from backend or from another app, I would recommend you to create a Z table on your backend and to insert all the components you want to create. After create an EntitySet wich returns it.

On the end, on the onInit method of your app controller, do read request and read the table. and build all the components and insert them in the view using JS.

Also it's much easier to debug this way.