我有一个带有odata的渲染表
这是我的控制器:
var oTable = this.getTable();
var oControl = new sap.ui.commons.TextField().bindProperty("value", "OBJ_KEY");
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text:"OBJ_KEY"}),
template :oControl,
sortProperty :"OBJ_KEY",
filterProperty :"OBJ_KEY",
width :"10%"
}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "OBJ_TXT");
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text:"OBJ_TXT"}),
template :oControl,
sortProperty :"OBJ_TXT",
filterProperty :"OBJ_TXT",
width :"40%"
}));
oTable.setModel(this.oModel);
var oSorter = new sap.ui.model.Sorter("OBJ_KEY");
oTable.bindRows("/MATGR1", oSorter);
这是我的观点:
<Table id="sap_m_Page_0-content-build_simple_Table-1534593457799" width="50%" noDataText="No data" mode="None" showSeparators="All" growing="true" growingThreshold="20" growingScrollToLoad="true" items="{plants>/MATGR1}">
<infoToolbar>
<Toolbar width="100%" height="auto" design="Auto" visible="false" enabled="true">
<content>
<Label text="Label" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit" visible="true"/>
</content>
</Toolbar>
</infoToolbar>
<headerToolbar>
<OverflowToolbar width="auto" height="auto" design="Transparent" visible="true" enabled="true">
<content>
<Title text="Розничный торговый оборот" titleStyle="Auto" width="auto" textAlign="Begin" visible="true" wrapping="false"/>
<ToolbarSpacer width=""/>
<OverflowToolbarButton text="Sort" type="Transparent" icon="sap-icon://sort" iconFirst="true" width="auto" enabled="true" visible="true" iconDensityAware="false" press="_onOverflowToolbarButtonPress"/>
<OverflowToolbarButton text="Filter" type="Transparent" icon="sap-icon://filter" iconFirst="true" width="auto" enabled="true" visible="true" iconDensityAware="false" press="_onOverflowToolbarButtonPress1"/>
<OverflowToolbarButton text="Group" type="Transparent" icon="sap-icon://group-2" iconFirst="true" width="auto" enabled="true" visible="true" iconDensityAware="false" press="_onOverflowToolbarButtonPress2"/>
<OverflowToolbarButton text="Settings" type="Transparent" icon="sap-icon://action-settings" iconFirst="true" width="auto" enabled="true" visible="true" iconDensityAware="false" press="_onOverflowToolbarButtonPress3"/>
</content>
</OverflowToolbar>
</headerToolbar>
<columns>
<Column width="auto" hAlign="Left" vAlign="Top" minScreenWidth="Phone" demandPopin="false" popinDisplay="Inline" mergeDuplicates="false">
<header>
<Text text="Наименование" width="auto" maxLines="1" wrapping="false" textAlign="Begin" textDirection="Inherit" visible="true"/>
</header>
<footer/>
</Column>
<Column width="auto" hAlign="Left" vAlign="Top" minScreenWidth="Phone" demandPopin="false" popinDisplay="Inline" mergeDuplicates="false">
<header>
<Text text="Сумма" width="auto" maxLines="1" wrapping="false" textAlign="Begin" textDirection="Inherit" visible="true"/>
</header>
<footer/>
</Column>
</columns>
<items>
<ColumnListItem type="Active" press="_onRowPress">
<cells>
<ObjectIdentifier title="{plants>OBJ_KEY}" text="{plants>OBJ_TXT}" titleActive="false" visible="true"/>
</cells>
</ColumnListItem>
</items>
</Table>
所以我接下来要做的是:当我点击表格中的一行时,表格应该自己刷新数据。它就像一个层次结构,因为在表格中我们第一次有类别:“食物,配件等”,当我点击食物(例如)时,表格应该刷新数据“奶制品,糖果,饮料等”。但是我对刷新有一个问题,因为SAP在它已经绑定时不允许刷新数据。
我的onpress活动:
var oTable = this.byId("sap_m_Page_0-content-build_simple_Table-1534593457799");
var oControl = new sap.ui.commons.TextField().bindProperty("value", "OBJ_KEY");
oControl = new sap.ui.commons.TextField().bindProperty("value", "OBJ_TXT");
oTable.setModel(this.oModel);
var oSorter = new sap.ui.model.Sorter("OBJ_KEY");
oTable.bindRows("/MATGR2", oSorter);
首先,我们应该从表中删除所有项目。因此我们这样选择自己的表格:
var oTable = this.getView().byId("TABLE_ID");
然后我们从数据中清除我们的表:
oTable.unbindItems();
绑定新项目:
oTable.bindItems("OUR_MODEL>/OUR_DATA_VIEW",
new sap.m.ColumnListItem( {
type: "Active",
cells: [
new sap.m.Text({ label: "{OUR_MODEL>VIEW_ITEM}", text: "{OUR_MODEL>VIEW_ITEM}" })
]
})
);
那一切。