cancel
Showing results for 
Search instead for 
Did you mean: 

SmartField dependency filter

CristianBabei
Contributor
0 Kudos

I have the following scenario:

A form binded to an entityset, I'm using annotations and have some smartFields.

The fields have their valueHelp binded to an getEntity. The thing is that I need to pass some custom filters to my smartField after they fill some of the inputs, like when you filter a list :

var oFilter = new Filter({ path: "...", operator: FilterOperator.EQ, value1: '....'});

var oBindings = sap.ui.getCore().byId(".......").getBinding("items"); 
oBindings.filter([oFilter]);
This is how I bind my form:
sap.ui.getCore().byId("form").bindElement("/TestSet('00')");

And my view:

<smartField:SmartField id="iSelectMotivo" value="{MotivoCrm}">
     <smartField:configuration>
        <smartField:Configuration controlType="input" displayBehaviour="idAndDescription"/>
     </smartField:configuration>
</smartField:SmartField>

Any tips how can I archive this?


(Similar question https://answers.sap.com/questions/32849/pass-filter-to-value-help-of-smartfield.html
none answerd, 1 year ago)

Thx in advance.


Accepted Solutions (1)

Accepted Solutions (1)

CristianBabei
Contributor
0 Kudos

Solved it.

Seems, all Smart Objects, have inside the proper component it uses, so for example in a SmartField type Select, it has a sap.m.select inside, and when you access this one, is the same as for all other components, get the binding context and then filter.

_onCategoryChange: function(oEvent){
      var vValue = oEvent.getSource().getValue();
      var oFilter = new sap.ui.model.Filter({
                path: "Test",
                operator: sap.ui.model.FilterOperator.EQ,
                value1: vValue
      });
      //var oSubcategory   = sap.ui.getCore().byId('SFIESubcategory');    //This is the SmartField
      var oSubcategoryList = sap.ui.getCore().byId("SFIESubcategory").getContent();
      var oBinding         = oSubcategoryList.getBinding("items");
      oBinding.filter[oFilter];
},

Answers (0)