cancel
Showing results for 
Search instead for 
Did you mean: 

Filter Associations at XML View

philipp_steidl
Explorer
0 Kudos

i have items from an association bound to a Table.

if i do it in this way it works:

<Table id="tbl1" items="{layerCompAss}" headerText="header" growing="true" >

but i need to add a Filter to this table and i tried it in this way:

<Table id="tbl1"

  items="{

    path: '/layerCompAss',

    filters: [{

        Comptyp: 'H'

    }]

}"

  headerText="header" growing="true" >

but this does not work.

Any idea how that works?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

philipp_steidl
Explorer
0 Kudos

thanks, but it is still not working.

for me the problem seems to be that items="{layerCompAss}" is not the same than

items="{ path:'/layerCompAss' }"

any idea?

Former Member
0 Kudos

How could both be the same ? In the second one, you have the slash in the path which means that its'an absolute binding whereas the first one is a relative binding path. So your binding path should be without slash.

items="{ path:'layerCompAss' }"
philipp_steidl
Explorer
0 Kudos

Thanks, it works now with this syntax:

<Table items="{path:'layerCompAss',filters: [{ path: 'Comptyp', operator: 'Contains', value1: 'H'}] } growing="true" >

Answers (4)

Answers (4)

philipp_steidl
Explorer
0 Kudos

i try to explain it in detail:

my view looks like this:

<List backgroundDesign="Transparent" items="{itemLayerAss}"  id="componentList" growing="true">

  <CustomListItem>

<Table id="SchleifmittelKomponenten" items="{layerCompAss}"

headerText="Schleifmittel" growing="true>

//Table Content

</Table> 

  </CustomListItem>

  </List>

Both Entitys are Associations ( itemLayer Ass and LayerCompAss )

What i want to do is to add a Filter to the second Table ( with Binding layerCompAss ) due to the fact that it is much easier with association entities i want to filter at the xml view instead of filtering at the context.

but if i try it in this way:

<Table id="SchleifmittelKomponenten" items="{

    path: '/layerCompAss',

    filters: [{

        Comptyp: 'H'

    }]

}" headerText="Schleifmittel" growing="true" >

the model trys to resolve the path <service path>/layerCompAss instead of <service path>/relatedEntity of base table/layerCompAss.

is there no way to handle this via the xml view?

monalisa_biswal
Contributor
0 Kudos

Hi Philipp,

Please specify filter as below:

<Table id="SchleifmittelKomponenten"

   items="{path: '/layerCompAss',filters: [{ path: 'Comptyp', operator: 'Contains', value1: 'H'}] }" growing="true" >

If it is one level below the item association specify as below

<Table id="SchleifmittelKomponenten"

   items="{path: '/layerCompAss',filters: [{ path: 'Association2/Comptyp', operator: 'Contains', value1: 'H'}] }" growing="true" >

Hope it helps!

Thanks,

Mona

former_member182372
Active Contributor
0 Kudos

include name of the association (layerComp) as part of the field name in filter

layerComp/Comptyp

philipp_steidl
Explorer
0 Kudos

hi,

the issue is not with the filters - the issue is that the association does not work anymore.

this is the association definition:

<Association Name="layerComp" sap:content-version="1">

                <End Type="/TYED/CA_OSKAR_SRV.layer" Multiplicity="*" Role="FromRole_layerComp"/>

                <End Type="/TYED/CA_OSKAR_SRV.comp" Multiplicity="*" Role="ToRole_layerComp"/>

                <ReferentialConstraint>

                    <Principal Role="FromRole_layerComp">

                        <PropertyRef Name="Matnr"/>

                        <PropertyRef Name="Aufnr"/>

                        <PropertyRef Name="Laynr"/>

                    </Principal>

                    <Dependent Role="ToRole_layerComp">

                        <PropertyRef Name="Matnr"/>

                        <PropertyRef Name="Aufnr"/>

                        <PropertyRef Name="Laynr"/>

                    </Dependent>

                </ReferentialConstraint>

            </Association>

but as soon as i use it within the path attribute it does not work anymore.

former_member182372
Active Contributor
0 Kudos

sorry, i dont really follow you

former_member182372
Active Contributor
0 Kudos

<Table items = "{path : '/Tracks', filters: [{ path: 'MyApprovals', operator: 'EQ', value1: 'true'}] }"

santhu_gowdaz
Active Contributor
0 Kudos

you need to add filters with ui.model.filter like below,

items: {

  path: "metadatamodel>/allprojects",

  template: new sap.ui.core.ListItem({

  text: "{metadatamodel>projectDescription}",

  key: "{metadatamodel>projectKey}"

  }),

  filters: [new sap.ui.model.Filter("projectClient", sap.ui.model.FilterOperator.EQ, "{tablemodel>client}")]

  }

check this link-https://github.com/SAP/openui5/issues/130

philipp_steidl
Explorer
0 Kudos

but this is not the solution for the XML View -> and also not for the associations.

i know how to add filters on entities at the controller, but here i want to add it at the XML view to use the association advantages.

thanks