首页 > 解决方案 > SAPUI5 响应式表多选集选定记录

问题描述

我有一个具有多选模式的 SAPUI5 响应表。而且我需要在将数据加载到表时显示选定的记录。找不到在响应表中设置选定记录的方法。

<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>

有没有办法在表格中设置选定的行并显示选定的记录。

标签: htmlsapui5sap-fiori

解决方案


您可以使用selectedColumnListItem 中的属性。

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

小提琴


推荐阅读