Skip to Content
0
Dec 05, 2021 at 11:23 AM

Sapui5 Smartfilterbar setMandatory Not Working

221 Views Last edit Dec 05, 2021 at 03:38 PM 3 rev

Hello guys,

I want the "Pernr" search help to be mandatory when only "01" is selected from my "Empty type (Zmtrk)" search help field in the smartfilterbar. From the mandatory Search help, I want some search help to be mandatory according to the selected data. How do I do this? setMandatory did not work. Is there any other method?

Main.xml

<smartFilterBar:SmartFilterBar id="smartFilterBar" entityType="GetData" smartVariant="PageVariant" persistencyKey="PKeyFilterbar" useDateRangeType="true" <br>filterChange="filterChange" search="onSearch">
	<smartFilterBar:controlConfiguration>
		<smartFilterBar:ControlConfiguration id="zmtrk" key="Zmtrk" label="{/#GetData/Zmtrk/@sap:label}" controlType="dropDownList"
			preventInitialDataFetchInValueHelpDialog="false" visibleInAdvancedArea="true" index="1" filterType="single" mandatory="mandatory"/>
		<smartFilterBar:ControlConfiguration id="pernr" key="Pernr" label="{/#GetData/Pernr/@sap:label}"
			preventInitialDataFetchInValueHelpDialog="false" visibleInAdvancedArea="true" index="2" filterType="multiple"/>
		<smartFilterBar:ControlConfiguration key="Kostl" label="{/#GetData/Kostl/@sap:label}" preventInitialDataFetchInValueHelpDialog="false"
			visibleInAdvancedArea="true" index="3" filterType="multiple" mandatory="notMandatory"/>
		<smartFilterBar:ControlConfiguration key="Anln1" label="{/#GetData/Anln1/@sap:label}" preventInitialDataFetchInValueHelpDialog="false"
			visibleInAdvancedArea="true" index="4" filterType="multiple" mandatory="notMandatory"/>
		<smartFilterBar:ControlConfiguration key="Anln2" label="{/#GetData/Anln2/@sap:label}" preventInitialDataFetchInValueHelpDialog="false"
			visibleInAdvancedArea="true" index="5" filterType="multiple" mandatory="notMandatory"/>
		<smartFilterBar:ControlConfiguration key="Erdat" label="{/#GetData/Erdat/@sap:label}" preventInitialDataFetchInValueHelpDialog="false"
			visibleInAdvancedArea="true" index="6" mandatory="notMandatory" conditionType="sap.ui.comp.config.condition.DateRangeType"/>
	</smartFilterBar:controlConfiguration>
</smartFilterBar:SmartFilterBar><br>

Main.controller.js

filterChange: function(oEvent) {
       if (ZmtrkKey === "03") {
		this.getView().byId("pernr").setMandatory("mandatory");
		// globalModel.setProperty("/pernrMandatory", "mandatory");
	}
}

I would be glad if you help.