文本字符串作为格式化程序函数中的参数

时间:2023-01-14 18:38:58

I would like pass to my formatter function a string params that i write in xml code:

我想传递给我的格式化程序函数一个字符串参数,我用xml代码编写:

Something like this:

像这样的东西:

visible="{path: 'this_is_my_custo_param_01_02_03', formatter: 'ui5bp.Formatter.myFunction'}"

This is the dual Question of Use custom global function in Expression Binding

这是表达式绑定中使用自定义全局函数的双重问题

2 个解决方案

#1


0  

That is not supported. Formatter functions are only called, when a actual binding to a Model is updated.

这不受支持。仅在更新与模型的实际绑定时才调用Formatter函数。

Also you cannot pass additional literal values to the formatter function.

此外,您不能将其他文字值传递给formatter函数。

Typically this dynamic configuration is performed in Controller.onInit(). Either by accessing specific controls by id or by creating a separate viewmodel that you bind the properties to in the XMLView.

通常,此动态配置在Controller.onInit()中执行。通过id访问特定控件或创建一个单独的viewmodel,将属性绑定到XMLView中。

You can create a custom formatter function for each parameter value and let them call your function with the parameter.

您可以为每个参数值创建自定义格式化程序函数,并让它们使用参数调用您的函数。

Perhaps that is applicable in your case? If not please tell us more about your intentions.

也许这适用于您的情况?如果没有,请告诉我们更多关于您的意图。

#2


0  

In myFunction(sVal) -> sVal will be holding your string which you have passed in your XML view for path

在myFunction(sVal)中 - > sVal将保存您在XML视图中传递的字符串

Custom Formatter

#1


0  

That is not supported. Formatter functions are only called, when a actual binding to a Model is updated.

这不受支持。仅在更新与模型的实际绑定时才调用Formatter函数。

Also you cannot pass additional literal values to the formatter function.

此外,您不能将其他文字值传递给formatter函数。

Typically this dynamic configuration is performed in Controller.onInit(). Either by accessing specific controls by id or by creating a separate viewmodel that you bind the properties to in the XMLView.

通常,此动态配置在Controller.onInit()中执行。通过id访问特定控件或创建一个单独的viewmodel,将属性绑定到XMLView中。

You can create a custom formatter function for each parameter value and let them call your function with the parameter.

您可以为每个参数值创建自定义格式化程序函数,并让它们使用参数调用您的函数。

Perhaps that is applicable in your case? If not please tell us more about your intentions.

也许这适用于您的情况?如果没有,请告诉我们更多关于您的意图。

#2


0  

In myFunction(sVal) -> sVal will be holding your string which you have passed in your XML view for path

在myFunction(sVal)中 - > sVal将保存您在XML视图中传递的字符串

Custom Formatter