Skip to Content
avatar image
Former Member

Binding items from model to Table by Rows and not by Colums

Hello Community,

could any of you know how to solve my following problem?

https://stackoverflow.com/questions/46956009/ui5-binding-items-to-tablerows-instead-of-tablecolumns


best regards, Okyanus

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Oct 27, 2017 at 07:03 AM

    Hi Okyanus,

    If you visualize differently, you're essentially trying to bind the rows to the table itself!! Just that the "data" for your table as coming from the back-end needs to probably be re-structured. Maybe you could change it to something like this:

    Lets call the properties to which the cells need to be bound as: "C1Data", "C2Data" and "C3Data"

    In the view: Use 3 columns with column list item row template cells bound to C1Data, C2Data and C3Data.

    Your data will look like

    [ {"C1Data": "data for column1", "C2Data": "data for column2", "C3Data": "data for column3"},...]

    var vergleichTable1 = new sap.m.Table(this.createId("vergleichTable1"), {
    
            columns: [
                new sap.m.Column({
                    header: new sap.m.Label({
                        text: "Header Text 1"
                    })
                }),
                new sap.m.Column({
                    header: new sap.m.Label({
                        text: "Header Text 2"
                    })
                }),
                new sap.m.Column({
                    header: new sap.m.Label({
                        text: "Header Text 3"
                    })
                }),
            ],
            items: {
                 path: '<path to your entity',
                 template: new sap.m.ColumnListItem({
                    cells: [
                        new sap.m.Text({
                            text:  "{C1Data}"
                        }),
                        new sap.m.Text({
                            text:  "{C2Data}"
                        }),
                        new sap.m.Text({
                            text:  "{C3Data}"
                        })
                    ]
                 })
        }).addStyleClass("vergleichTable1");
    
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello, thanks for your reply but I have no idea how to do what you said.

      I dont recieve that "data" variable from the DB , i took it from my model.oData

  • Oct 27, 2017 at 07:31 AM

    Hi,

    If I understand correctly you have to transpose the data first ( Transpose ) and then bind items normally.

    Is that correct?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello yes exactly. because as I shared on the post on SO on the photo, the compared items must be horizontal

  • avatar image
    Former Member
    Nov 13, 2017 at 07:24 AM

    still didn't find any solutions

    Add comment
    10|10000 characters needed characters exceeded