Openui5: FacetFilter search does not work when binding uses a factory function rather than a template.

Created on 7 Mar 2020  Â·  3Comments  Â·  Source: SAP/openui5

I am trying to use a FacetFilterList. I am using data binding to an OData model, both for creating the lists, as wel as for populating the lists with items. The lists get populated but a runtime error occurs when searching the list:

Uncaught TypeError: Cannot read property 'getBindingInfo' of undefined
    at f.h._search (FacetFilterList-dbg.js:591)
    at f.h._handleSearchEvent (FacetFilterList-dbg.js:548)
    at f.b.fireEvent (EventProvider-dbg.js:243)
    at f.d.fireEvent (Element-dbg.js:558)
    at f.fireLiveChange (ManagedObjectMetadata-dbg.js:782)
    at f.b.onInput (SearchField-dbg.js:553)
    at HTMLInputElement.dispatch (jquery-dbg.js:4742)
    at HTMLInputElement.c3.handle (jquery-dbg.js:4554)

I tried to implement my own handler for the search event, but from this documentation I am getting the impression this is not possible:

https://sapui5.hana.ondemand.com/sdk/#/topic/559f60eaf71b47bb9f11a07622880f7c

The code I used to bind the items looks like this:

          facetFilterList.bindItems({
            //use the aggregate entity - not the original one
            path: modelName + '>/' + entitySet.name + '__A',
            parameters: {
              select: columnName
            },
            sorters: new Sorter({
              path: columnName
            }),
            factory: function(facetFilterListId, context){
              var facetFilterItem = new FacetFilterItem();
              facetFilterItem.bindProperty('key', {
                path: modelName + '>' + columnName 
              });
              facetFilterItem.bindProperty('text', {
                path: modelName + '>' + columnName,
                type: this.typeFactory(columnMetadata),
                formatOptions: this.formatOptionsFactory(columnMetadata)
              });
              return facetFilterItem;
            }.bind(this)

I think this is a bug in ui5. The problem is in this line in FacetFilterList:

https://github.com/SAP/openui5/blob/7e593fbd9f750e52bdb5d70d0d08606d0e75bd3b/src/sap.m/src/sap/m/FacetFilterList.js#L627

This reads:

var aBindingParts = this.getBindingInfo("items").template.getBindingInfo("text").parts;

I think this shows that search is only supported when binding was done through a template - not when using a factory function (like in my code).

I suppose the workaround is to use a template, and not a factory function. However, if that is the case, and there is no intention of supporting it when using a factory function, then the documentation should make this clear.
Or there should be a way to override the search functionality so I can handle the search myself.

bug fixed

Most helpful comment

Hello @rpbouman,

The issue is now fixed. It will be possible to bind the sap.m.FacetFilterList items by using a factory function. As of UI5 1.76 it will be possible to register a handler to "search" event emitted from the sap.m.FicetFilterList and define filtering logic at application level. These functionalities will come with updated documentation and will be available about 26 Match.

Thank you and Best Regards,
Boyan

All 3 comments

Hello @rpbouman ,
Thank you for sharing this finding. I've created an internal incident 2070068276. The status of the issue will be updated here in GitHub.

Regards,
Gery

Hello @rpbouman,

The issue is now fixed. It will be possible to bind the sap.m.FacetFilterList items by using a factory function. As of UI5 1.76 it will be possible to register a handler to "search" event emitted from the sap.m.FicetFilterList and define filtering logic at application level. These functionalities will come with updated documentation and will be available about 26 Match.

Thank you and Best Regards,
Boyan

That was quick. Thanks! Much obliged :)

On Fri, Mar 13, 2020 at 10:48 AM Boyan Rakilovski notifications@github.com
wrote:

Hello @rpbouman https://github.com/rpbouman,

The issue is now fixed. It will be possible to bind the
sap.m.FacetFilterList items by using a factory function. As of UI5 1.76 it
will be possible to register a handler to "search" event emitted from the
sap.m.FicetFilterList and define filtering logic at application level.
These functionalities will come with updated documentation and will be
available about 26 Match.

Thank you and Best Regards,
Boyan

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/SAP/openui5/issues/2837#issuecomment-598638809, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAE6BE3AKSKTEJSBJDZUT23RHH6QVANCNFSM4LDK3K6Q
.

--
Roland Bouman
blog: http://rpbouman.blogspot.com/
twitter: @rolandbouman
linkedin: http://www.linkedin.com/profile/view?id=5142800&trk=tab_pro

Was this page helpful?
0 / 5 - 0 ratings