有没有办法从 sap.ui.table.Table 中获取一行的值

Is there any way to get the values of a row from sap.ui.table.Table

我知道 sap.ui.table.Table 让您可以使用 MultiToggle selectionMode。这会添加一个带有复选框的列。有什么方法可以使用该复选框 select 一行并在我的控制器中获取该行值。我在不在我的控制器中的 xml 视图中定义了我的 table 控件。使用此设置可以检索单行并获取该行的值。每行都有一个嵌套的文本区域和标签。

这是我的看法

    <mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:t="sap.ui.table"
    controllerName="ariba.so.kaaguidedassistance.controller.GuidedAssistance" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:l="sap.ui.layout">
    <Page title="Guided Assistance Flow Page">
        <content>
            <Toolbar id="toolbar1">
                <Button text="update" press="onSubmit"></Button>
                <Button text="add Guided Assistance QA" press="onAddGAQA"></Button>
                <Button text="add Guided Assistance Keywords QA" press="onAddGAKQA"></Button>
                <Button text="delete" press="onNavigateDelete"></Button>
                <ToolbarSpacer/>
                <ToolbarSpacer/>
            </Toolbar>
            <t:Table id="GAQA" rows="{guidedAssistanceGA>/data}" title="Guided Assistance QA" selectionMode="MultiToggle" visibleRowCount="7">
                <t:Column width="11rem">
                    <Label text="ID"/>
                    <t:template>
                        <Label text="{guidedAssistanceGA>ID}"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="value_long"/>
                    <t:template>
                        <TextArea id="value_long" value="{guidedAssistanceGA>value_long}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Type"/>
                    <t:template>
                        <TextArea id="type" value="{guidedAssistanceGA>Type}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Action"/>
                    <t:template>
                        <TextArea id="Action" value="{guidedAssistanceGA>Action}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Button1"/>
                    <t:template>
                        <TextArea id="Button1" value="{guidedAssistanceGA>Button1}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Button2"/>
                    <t:template>
                        <TextArea id="Button2" value="{guidedAssistanceGA>Button2}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Button3"/>
                    <t:template>
                        <TextArea id="Button3" value="{guidedAssistanceGA>Button3}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Button4"/>
                    <t:template>
                        <TextArea id="Button4" value="{guidedAssistanceGA>Button4}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Button5"/>
                    <t:template>
                        <TextArea id="Button5" value="{guidedAssistanceGA>Button5}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Button6"/>
                    <t:template>
                        <TextArea id="Button6" value="{guidedAssistanceGA>Button6}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Active_Flag"/>
                    <t:template>
                        <TextArea id="Active_Flag" value="{guidedAssistanceGA>Active_Flag}" width="100%"/>
                    </t:template>
                </t:Column>
            </t:Table>
            <Toolbar id="toolbar2">
                <ToolbarSpacer/>
                <ToolbarSpacer/>
            </Toolbar>
            <t:Table id="GAKQA" rows="{guidedAssistanceGAK>/data}" title="Guided Assistance Keywords QA" selectionMode="MultiToggle" visibleRowCount="7">
                <t:Column width="11rem">
                    <Label text="Flow_ID"/>
                    <t:template>
                        <Label text="{guidedAssistanceGAK>Flow_ID}"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Keywords"/>
                    <t:template>
                        <TextArea id="Keywords" value="{guidedAssistanceGAK>Keywords}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Intersection1"/>
                    <t:template>
                        <TextArea id="Intersection1" value="{guidedAssistanceGAK>Intersection1}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Intersection2"/>
                    <t:template>
                        <TextArea id="Intersection2" value="{guidedAssistanceGAK>Intersection2}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Logic_Group"/>
                    <t:template>
                        <TextArea id="Logic_Group" value="{guidedAssistanceGAK>Logic_Group}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Logic_Order"/>
                    <t:template>
                        <TextArea id="Logic_Order" value="{guidedAssistanceGAK>Logic_Order}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="Points"/>
                    <t:template>
                        <TextArea id="Points" value="{guidedAssistanceGAK>Points}" width="100%"/>
                    </t:template>
                </t:Column>
                <t:Column width="11rem">
                    <Label text="ID"/>
                    <t:template>
                        <Label text="{guidedAssistanceGAK>ID}"/>
                    </t:template>
                </t:Column>
            </t:Table>
        </content>
    </Page>
</mvc:View>

我希望在我的控制器中检索其中一行的值。该值在我的标签和文本区域中。

只需查看 sap.ui.table 的 API 文档即可。 https://openui5.hana.ondemand.com/#/api/sap.ui.table.Table/methods/getContextByIndex

您可以使用 getSelectedIndexgetSelectedIndices 来确定当前选择了哪些行。 getContextByIndex 方法为您提供包含所有值的一行对象。