cancel
Showing results for 
Search instead for 
Did you mean: 

SmartFilterBar does not work after navigation

almedin_hodzic53
Participant
0 Kudos
697

From 2 places in my application I navigate to the one view which is used for Person Searching.


When I navigate from one place of the app, it works as expected.

But, when I navigate from the second place, it does not.

Code is the same for both places, as it use same view and controller...

Message in console I get:

SmartFilterBar.getControlByKey: called before the SmartFilterBar is initialized .

                            <smartFilterBar:SmartFilterBar 
id="idEmployeeSmartFilter"
entitySet="empl"
showClearOnFB="true"
clear="onClear"
>
<smartFilterBar:controlConfiguration>
<smartFilterBar:ControlConfiguration
key="Lastname"
hasValueHelpDialog="false"
filterType="single"
visibleInAdvancedArea="true"
index="1"
label="{i18n>lastName}"
/>
<smartFilterBar:ControlConfiguration
key="Firstname"
hasValueHelpDialog="false"
filterType="single"
visibleInAdvancedArea="true"
index="2"
label="{i18n>firstName}"
/>
<smartFilterBar:ControlConfiguration
key="Department"
hasValueHelpDialog="false"
filterType="single"
visibleInAdvancedArea="true"
index="3"
label="{i18n>department}"
/>
<smartFilterBar:ControlConfiguration
key="Email"
hasValueHelpDialog="false"
filterType="single"
visibleInAdvancedArea="true"
index="4"
label="{i18n>adEmail}"
/>
</smartFilterBar:controlConfiguration>
</smartFilterBar:SmartFilterBar> <smartTable:SmartTable
smartFilterId="idEmployeeSmartFilter"
id="idEmployeeSmartTable"
entitySet="empl"
enableAutoBinding="true"
tableType="ResponsiveTable"
requestAtLeastFields="*"
useExportToExcel="false"
useTablePersonalisation="false"
useVariantManagement="false"
> ..... </smartTable:SmartTable>
View Entire Topic
leonikussmaul
Product and Topic Expert
Product and Topic Expert

Hi Almedin

As per the error message,your SmartFilterBar is not initialized every time the view is loaded, regardless of where it is being navigated from. The SmartFilterBar fires the initialise event only once after the metadata is analyzed and the inner state is initialised for the first time.

This code checks if the SmartFilterBar control is already initialized. If it is, the necessary code is executed immediately. If it is not, a callback function is attached to the initialise event. This callback function will execute the necessary code once the control has been initialized.

if(oSmartFilterBar.isInitialised()){
//run some code after initialization
} else {
oSmartFilterBar.attachInitialise();
//run some code after initialization
oSmartFilterBar.getControlByKey("filter");
}
akashem
Discoverer
0 Kudos

for me working

onInit: function () {
            const oODataModel = this.getOwnerComponent().getModel();
            this.getView().setModel(oODataModel);
            this.getOwnerComponent().getRouter().getRoute("Page11").attachPatternMatched(this.onRoutePatternMatched, this);
           
        },
        onRoutePatternMatched: function () {
            const smartFilterBar = this.getView().byId("id11SmartFilterBar");
            if (smartFilterBar) {
                if (!smartFilterBar.isInitialised()) {
                    smartFilterBar.attachInitialise(function () {
                        smartFilterBar.search();
                    });
                } else {
                    smartFilterBar.search();
                }
            }
           
        }