cancel
Showing results for 
Search instead for 
Did you mean: 

Appending data to table getting failed in webide.

former_member593030
Participant
0 Kudos
155

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

Accepted Solutions (1)

Accepted Solutions (1)

junwu
SAP Champion
SAP Champion

how you initialize the model?

if it is empty,

itemData=[];
then 
itemData.push(itemRow);

Answers (0)