Skip to Content
avatar image
Former Member

Filter Associations at XML View

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 11, 2015 at 06:18 PM

    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?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Thanks, it works now with this syntax:

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

  • avatar image
    Former Member
    Sep 11, 2015 at 04:04 PM

    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?

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 11, 2015 at 12:29 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • Sep 11, 2015 at 12:34 PM

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 11, 2015 at 01:42 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded