cancel
Showing results for 
Search instead for 
Did you mean: 

How to skip items for aggregation binding when using factory function

Former Member
0 Kudos

Hi there,

I'm using a sap.m.List and do aggregation binding using a factory function. I need to use a factory function as I create a custom control for the sap.m.List.

However, when getting all the entries for the data binding for my factory function, I need to skip some entries, for example when a status is not the right value.

When returning null in the factory function, the data binding fails.

TypeError: Cannot read property 'setBindingContext' of null

Is there a way to skip creation of a UI element for data binding when using a factory function?

Regards

Tobias

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Tobias,

Can you post your code?

Regards,

RW

Former Member
0 Kudos

It looks something like this:


                        new sap.m.List( {

                            items : {

                                path    : "/some_data_entries",

                                factory : function( id, context ) {

                                    var data_path = context.getPath();

                                    var single_data = context.getProperty( data_path );

                                    if( single_data.status != "20" ) {

                                        return null;

                                    }

After the return I will create a new CustomListItem, which works just fine.

jmoors
Active Contributor
0 Kudos

Can't use use a filter to remove the unwanted items?

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

Many thanks,

Jason

Former Member
0 Kudos

Jason,

haven't thought about this solution yet. For this special case this solution will work.

However, for more complex conditions not covered by the available filter methods, a solution would not be that easy.

To fix my issue, a filter will work.

Regards

Tobias

Answers (0)