cancel
Showing results for 
Search instead for 
Did you mean: 

Sapui5 Smartfilterbar setMandatory Not Working

fdemir
Explorer
0 Kudos
934

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.

View Entire Topic
SAPSeeker
Participant
0 Kudos

Did you find a solution for this issue ? The method setMandatory can only be set during initialization. Changes at runtime are getting ignored.