如何解决如何在UI5中获取smartTable的选定行
我正在尝试选择用户检查过的所有Recod,但不能。 使用代码:
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>
这是我的控制者:
onInit: function () {
this.getView().addStyleClass("sapUiSizeCompact");
var oConfig = this.getOwnerComponent().getModel("config");
var userName = oConfig.getProperty("/UserName");
var bpModel = this.getOwnerComponent().getModel("bpModel");
var oTable = this.getView().byId("bpTable");
//To-Do Bind Model to table
oTable.setModel(bpModel);
oTable.setEntitySet("OZPSTA_MON_ERROR");
oTable.setInitiallyVisibleFields("id","codigo_atena","hora","data","flag","tableName","field","erro","operacao");
},reprocessSelectedRecords: function (oEvent) {
var gettingInternalTable = this.byId("bpTable").getTable(),gettingAllRows = gettingInternalTable.getRows();
gettingAllRows.map(function (item) {
// get the selected rows
});
}
解决方法
您可以尝试通过以下方式获取选定的行-
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())
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。