Sapui5 如何在UI5中获取smartTable的选定行

Sapui5 如何在UI5中获取smartTable的选定行,sapui5,Sapui5,我正在尝试选择用户选中的所有记录,但我不能。 使用代码: var gettingInternalTable = this.byId("bpTable").getTable(), gettingAllRows = gettingInternalTable.getRows(); 我可以获取屏幕上显示的所有行,但我无法通过复选框进行筛选。 我正在使用smartTable显示数据 以下是我的链接: 我的看法是: <mvc:View xmlns="sap.m

我正在尝试选择用户选中的所有记录,但我不能。 使用代码:

var gettingInternalTable = this.byId("bpTable").getTable(),
    gettingAllRows = gettingInternalTable.getRows();
我可以获取屏幕上显示的所有行,但我无法通过复选框进行筛选。 我正在使用smartTable显示数据

以下是我的链接:

我的看法是:

<mvc:View xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" xmlns:smartTable="sap.ui.comp.smarttable"
    controllerName="opensap.odataBasic.controller.App" height="100%">
    <Page title="{i18n>appTitle}">
        <content>
            <smartTable:SmartTable id="bpTable" header="{i18n>UList}" editable="false" 
                                                   showRowCount="true" enableAutoBinding="true"
                showFullScreenButton="true" tableType="Table">
                <smartTable:layoutData>
                    <FlexItemData growFactor="1" baseSize="0%"/>
                </smartTable:layoutData>
                <smartTable:customToolbar>
                    <OverflowToolbar width="100%" id="toolbar2">
                        <content>
                            <Button xmlns="sap.m" text="Button" id="button" 
                                                                  press=".reprocessSelectedRecords"/>
                        </content>
                    </OverflowToolbar>
                </smartTable:customToolbar>
            </smartTable:SmartTable>
        </content>
    </Page>
</mvc:View>

您可以尝试以下方式获取所选行-

var gettingInternalTable = this.byId("bpTable").getTable(),
                gettingAllRows = gettingInternalTable.getRows();
                oSelIndices = gettingInternalTable.getSelectedIndices();
//oSelIndices will have index of the rows
for(var i of oSelIndices){
console.log(gettingAllRows[i].getBindingContext().getObject())
}

您可以尝试以下方式获取所选行-

var gettingInternalTable = this.byId("bpTable").getTable(),
                gettingAllRows = gettingInternalTable.getRows();
                oSelIndices = gettingInternalTable.getSelectedIndices();
//oSelIndices will have index of the rows
for(var i of oSelIndices){
console.log(gettingAllRows[i].getBindingContext().getObject())
}

如果您不需要访问该表,由于双向绑定,您的模型中应该已经有了这些信息。(尽管我从未使用过SmartTable,所以我可能是错的)如果您不需要访问该表,那么由于双向绑定,您的模型中应该已经有了这些信息。(我从未使用过SmartTable,所以我可能错了)非常感谢!很高兴能帮上忙。如果你发现它回答了你的问题,你可以接受它。非常感谢!很高兴能帮上忙。如果你发现它回答了你的问题,你可以接受它。