简体   繁体   中英

SAPUI5 formatter function not found

I know this question has been asked before here but the answer didn't help me.

This is my controller code:

 sap.ui.define([
        // there's more stuff importet here    
       'project/util/formatter',
    ], function (formatter ) {
       'use strict';
    return BaseController.extend('project.controller.ManualUpload', {

        formatter:formatter,

        onShowErrors: function() {
          //some other stuff happening here

        _.forEach(checkValidations, entry => {
            var errorMessage = oData[entry].ERROR_MSG;
            if(errorMessage) {
                var rowSettingsTemplate = new sap.ui.table.RowSettings({ highlight: "{ path: 'odataDetails>ERROR_MSG', formatter: '.formatter.errorStatus' }" }); 
                backendTable.setRowSettingsTemplate(rowSettingsTemplate);
            }
        });
       },
    });  
});

And this is my formatter with the function errorStatus()

sap.ui.define(function() {
    'use strict';
    return {
            errorStatus: function(errorMessage) {
            if (_.isEmpty(errorMessage)) {
                return 'None';
            } else {
                return 'Error';
            }    
        },    
    };
});

The formatter is found so this can't be the problem. Also I declared the formatter in the beginning of my controller, so that should be fine, too. Another suggested solution was the function call without parenthesis. I don't do this, so that can't be the problem either.

The error message is:

formatter function .formatter.errorStatus not found

I think the way you have attempted the binding is wrong.

In js view, you can bind as follows:

 var rowSettingsTemplate = new sap.ui.table.RowSettings({ highlight: { path: "odataDetails>ERROR_MSG", formatter: formatter.errorStatus } });

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM