我试图选择用户检查的所有记录,但我不能。 使用代码:
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())
}
我在提到的函数中只得到 5 行 但是在智能表中,我有40多行 oTable.getRows() (5) [c、c、c、c、c]
如何获取所有列?