cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Expression Binding - custom function call

Former Member
0 Likes
4,390

Hi all,

I read about new features in sapui5 - function call in expression binding:

Expression Binding - User Interface Add-On for SAP NetWeaver - SAP Library

On this page is only information, that we should call f(...). I try call my function (from view controler) but without success. Maybe someone has working example how to use this new feature, how to define function in view controler and how to use it in XML View?

I found similar question on: http://stackoverflow.com/questions/31615837/call-controller-function-from-xml-binding-expression

But solution from above page: "{= f(checkSelectedItems, null, ${odata>CustomerId}) }" doesn't work.

Thanks,

Maciej

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Likes

why would you use expression binding if you have to call function from controller anyway?

why dont use old formatter syntax?

{ parts : [ { path : 'odata>CustomerId' } ], formatter : '.checkSelectedItems' }

Former Member
0 Likes

@Maksim, your solution with formatter works great, it solved my problem. But still I don't know how to use custom function in expression binding.

Answers (3)

Answers (3)

Former Member
0 Likes

I'm using version 1.30.8 of SAPUI5 with data-sap-ui-xx-bindingSyntax="complex"

What I would like to have a mechanism to check user rights, for example:


<List

                id="menuList"

                mode="None"

                items="{

                    path : 'menu>/',

                    sorter : {

                        path : 'order',

                        descending: false

                    }

                }">

                <items>

                    <StandardListItem

                        title="{menu>label}"

                        visible="{= hasRights(${menu>permission},${user>/user/perms}) }"

                        type="Active"

                        description="{menu>desc}"

                        icon="sap-icon://{menu>icon}"

                        press="handleMenuListItemPress" >

                        <customData>

                            <core:CustomData

                                key="id"

                                value="{menu>id}" />

                        </customData>

                    </StandardListItem>

                </items>

            </List>

Or


<Button type="Save" press="save"  visible="{=  hasRights(${menu>permission},${user>/user/perms}) }"/>

On backend side I have already implemented security mechanism to check user rights, but I would like have also some easy to use on browser side. Function "hasRights" can work like  jQuery.inArray.


Maybe is other way to do this in proper way, but I think that in documentation we should find some example or maybe information how to use custom function in expression binding.

former_member182372
Active Contributor

the whole purpose of using expression binding is to eliminate simple formatter functions in controller

your case is not that, check here how i would implement it

JS Bin - Collaborative JavaScript Debugging

i did some debugging of that f(...) expression thing and it doesnt really looks promising, still haven't figured out how to call function from controllers instance.

former_member182372
Active Contributor
0 Likes

and of course check

by

1. bootstrap contains  data-sap-ui-xx-bindingSyntax="complex" ?

2. Expression binding introduced with 1.28 version.

santhu_gowdaz
Active Contributor
0 Likes

Expression binding is using for simple formatter function. so write the logic in xml view itself. and please share your code and your requirement.