table returns 最多 20 行的 getItems() 方法
getItems() method for table returns up to 20 rows
我有一个报告 table,它以三种不同的方式填充,具体取决于选择过滤器。在调用的报告结束时,我使用 "updateFinished" 事件循环遍历 table 条目,将它们绘制为斑马样式并将最后的摘要行绘制为粉红色。
SAPUI5 应用程序版本为 1.44.12
this.oStsTable = this.getView().byId("statusReportTable");
this.oStsTable.attachEventOnce("updateFinished", function(oEv) {
var aItems = oEv.getSource().getItems();
if (aItems && aItems.length > 0) {
for (var i = 0; i < aItems.length; i++) {
if (i === aItems.length - 1) {
aItems[i].addStyleClass("pinkBackground");
} else {
var even = i % 2;
if (even !== 0 && i < aItems.length) {
aItems[i].addStyleClass("cyanBackground");
}
}
}
}
});
this.byId("statusReportTable").getBinding("items").filter(oTableSearchState);
有了可用的数据,我得到了 3 个数据集。案例 1 为 7,案例 2 为 7,案例 3 为 23。对于前两种情况,一切正常。问题出在案例 3(23 条记录)上。在后端调试,我看到 23。当 table 出现时,我再次看到 23。但是 "updateFinished" 事件中的 getItems() 方法只看到 20(!)。结果(是的,猜对了),第 20 行变为粉红色,其余行在循环退出时没有颜色。
响铃了吗?
如果您只是想在最后一行添加不同颜色的斑马纹样式,我建议您只在您的应用中使用 CSS,如下所示。
table tr:nth-child(even) {
background-color: green;
}
table tr:nth-child(odd) {
background-color: red;
}
table tr:last-of-type {
background-color: yellow;
}
如果您只需要改变 sap.m.Table 上的行颜色,那么我建议您将 属性 alternateRowColors
设置为 true.
<Table id="idProductsTable"
alternateRowColors="true"
items="{ path: '/ProductCollection' }">
<headerToolbar>
<Toolbar>
<Title text="Products"/>
</Toolbar>
</headerToolbar>
<columns>
<Column>
<Text text="Product" />
</Column>
<Column>
<Text text="Supplier" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier title="{Name}" text="{ProductId}"/>
<Text text="{SupplierName}" />
</cells>
</ColumnListItem>
</items>
</Table>
注意:此属性只能与伯利兹和伯利兹深渊主题一起使用。交替行着色不适用于高对比度 Black/White 主题。
查找 sap.m.Table here.
的属性
我有一个报告 table,它以三种不同的方式填充,具体取决于选择过滤器。在调用的报告结束时,我使用 "updateFinished" 事件循环遍历 table 条目,将它们绘制为斑马样式并将最后的摘要行绘制为粉红色。
SAPUI5 应用程序版本为 1.44.12
this.oStsTable = this.getView().byId("statusReportTable");
this.oStsTable.attachEventOnce("updateFinished", function(oEv) {
var aItems = oEv.getSource().getItems();
if (aItems && aItems.length > 0) {
for (var i = 0; i < aItems.length; i++) {
if (i === aItems.length - 1) {
aItems[i].addStyleClass("pinkBackground");
} else {
var even = i % 2;
if (even !== 0 && i < aItems.length) {
aItems[i].addStyleClass("cyanBackground");
}
}
}
}
});
this.byId("statusReportTable").getBinding("items").filter(oTableSearchState);
有了可用的数据,我得到了 3 个数据集。案例 1 为 7,案例 2 为 7,案例 3 为 23。对于前两种情况,一切正常。问题出在案例 3(23 条记录)上。在后端调试,我看到 23。当 table 出现时,我再次看到 23。但是 "updateFinished" 事件中的 getItems() 方法只看到 20(!)。结果(是的,猜对了),第 20 行变为粉红色,其余行在循环退出时没有颜色。
响铃了吗?
如果您只是想在最后一行添加不同颜色的斑马纹样式,我建议您只在您的应用中使用 CSS,如下所示。
table tr:nth-child(even) {
background-color: green;
}
table tr:nth-child(odd) {
background-color: red;
}
table tr:last-of-type {
background-color: yellow;
}
如果您只需要改变 sap.m.Table 上的行颜色,那么我建议您将 属性 alternateRowColors
设置为 true.
<Table id="idProductsTable"
alternateRowColors="true"
items="{ path: '/ProductCollection' }">
<headerToolbar>
<Toolbar>
<Title text="Products"/>
</Toolbar>
</headerToolbar>
<columns>
<Column>
<Text text="Product" />
</Column>
<Column>
<Text text="Supplier" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier title="{Name}" text="{ProductId}"/>
<Text text="{SupplierName}" />
</cells>
</ColumnListItem>
</items>
</Table>
注意:此属性只能与伯利兹和伯利兹深渊主题一起使用。交替行着色不适用于高对比度 Black/White 主题。
查找 sap.m.Table here.
的属性