on 2019 May 21 2:19 PM
Hello All,
I need to add an empty table in view and after a click on Button, data need to be added in this table.
In View - Table is defined like this
<Panel expandable="true" expanded="true" width="auto" class="sapUiResponsiveMargin">
<content>
<Table id="packItem" items="{/gcn}" growing="true" growingThreshold="4" growingScrollToLoad="false">
<items>
<ColumnListItem id="itemlist">
<cells>
<Text text="{BSValue}" id="Sujoy"/>
<Text text="{ArticleCategory}" id="Sujoy1"/>
<Text text="{GROValue}" id="Sujoy2"/>
</cells>
</ColumnListItem>
</items>
<columns>
<Column id="BSValueT">
<header>
<Label text="BSValue" id="BSValueTV"/>
</header>
</Column>
</columns>
<columns>
<Column id="ArtCatT">
<header>
<Label text="Article Category" id="ArtCatTV"/>
</header>
</Column>
</columns>
<columns>
<Column id="GROValueT">
<header>
<Label text="GROValue" id="GROValueTV"/>
</header>
</Column>
</columns>
</Table>
</content>
</Panel>
In Controller - onChildAdd2 is Event Attach to Button
onChildAdd2:function(){
// Getting Value Here
var oBSValue = this.getView().byId("BSValue").getValue();
var oArticle = this.getView().byId("Article")._getSelectedItemText();
var oGRO = this.getView().byId("GROValue").getValue();
var itemRow = {
BSValue: oBSValue,
ArticleCategory:oArticle,
GROValue: oGRO
};
var oModel = this.getView().byId("packItem").getModel();
var itemData = oModel.getProperty("/gcn");
itemData.push(itemRow);
// Set Model
oModel.setData({gcn: itemData});
this.getView().byId("packItem").setModel("/", oModel);
},
So I am Getting - Cannot read property 'push' of undefined
Can you Please guide me What Wrong I am Doing here?
Regards,
Sujoy
Request clarification before answering.
how you initialize the model?
if it is empty,
itemData=[];
then
itemData.push(itemRow);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
72 | |
21 | |
9 | |
7 | |
6 | |
6 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.