tarzanbappa
tarzanbappa

Reputation: 4978

SAPUI5 Responsive table multi select set selected records

I have a SAPUI5 responsive table with multi-select mode. And I need to show the selected records when loading data to the table. Couldn't find a way to set selected records in the responsive table.

<Table id="idProductsTable"
        inset="false"
        mode="MultiSelect"
        alternateRowColors="true"
        items="{
            path: '/ProductCollection',
            sorter: {
                path: 'Name'
            }
        }">
        <headerToolbar>
            <OverflowToolbar>
                <Title text="Products" level="H2"/>
                <ToolbarSpacer/>
                <Label text="Multi selection modes" labelFor="idComboBoxSuccess"></Label>
                <ComboBox id="idComboBoxSuccess" selectedKey="Default" selectionChange=".onSelectionChange">
                    <core:Item text="Default" key="Default"></core:Item>
                    <core:Item text="ClearAll" key="ClearAll"></core:Item>
                </ComboBox>
            </OverflowToolbar>
        </headerToolbar>
        <columns>
            <Column width="12em">
                <Text text="Product" />
            </Column>
            <Column minScreenWidth="Tablet" demandPopin="true">
                <Text text="Supplier" />
            </Column>
            <Column minScreenWidth="Tablet" demandPopin="true" hAlign="End">
                <Text text="Dimensions" />
            </Column>
        </columns>
        <items>
            <ColumnListItem>
                <cells>
                    <ObjectIdentifier
                        title="{Name}"
                        text="{ProductId}"/>
                    <Text
                        text="{SupplierName}" />
                    <Text
                        text="{Width} x {Depth} x {Height} {DimUnit}" />
                </cells>
            </ColumnListItem>
        </items>
    </Table>

Is there a way to set the selected rows in the table and display selected records.

Upvotes: 0

Views: 2186

Answers (1)

alexP
alexP

Reputation: 3765

You can use selected property in ColumnListItem.

<ColumnListItem selected="{YourSelectedBoolean}">
   <cells>
       <ObjectIdentifier title="{Name}" text="{ProductId}"/>
       <Text text="{SupplierName}" />
       <Text text="{Width} x {Depth} x {Height} {DimUnit}" />
   </cells>
</ColumnListItem>

Fiddle

Upvotes: 2

Related Questions