cancel
Showing results for 
Search instead for 
Did you mean: 

Why am I getting same data in all rows?

01-21-2022 2:33 PM
1380 views 6 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

I have a table to which I am showing data from the model.

when I click on split button, a new row gets added.

Now if I change data in any 1 input field, all the input fields gets updated, and also the SubItem No is remaining same for all the rows, when I add new row the numbering will update for all. don't know what is wrong.

order qty, received qty unit is same for all the rows. posting qty and Batch will be different.

Below is the code I've written for model and to add new row when clicked on split button.

_getModelAndBindData: function() {
        this._aBatchItem = [];
        // first get the global model
        let oBatchItemModel = sap.ui.getCore().getModel("batchItem").getProperty("/");
        console.log(oBatchItemModel);
        oBatchItemModel.Postingquantity = "";

        let SubItemno = parseInt(oBatchItemModel.SubItemno);
        if (SubItemno === 0) {
            oBatchItemModel.SubItemno = 0;
            oBatchItemModel.SubItemno += 1;
        }
        this._aBatchItem.push(oBatchItemModel);
        let itemJsonModel = new JSONModel({
            results: this._aBatchItem
        });
        this.getView().byId("id_BatchSplit_table").setModel(itemJsonModel, "itemJsonModel");
    },

    onBatchSplitButtonPress: function(oEvent) {
        let oTableControlRef = oEvent.getSource().getParent().getParent();
        let oItemJsonModel = oTableControlRef.getModel("itemJsonModel");
        let localData = oItemJsonModel.getProperty("/results");

        this._aBatchItem[0].SubItemno = this._getUniqueSubItemno(oEvent);

        let oNewRow = this._aBatchItem[0];
        localData.push(oNewRow);
        oItemJsonModel.setProperty("/results", localData);
    },
0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

junwu
SAP Champion
SAP Champion
0 Likes

seems you are pushing same object again and again.

this._aBatchItem.push(oBatchItemModel);

put the new item in a object, then push

var newItem={}//fill it

then

this._aBatchItem.push(

newItem

);
Former Member
0 Likes

It worked.

Thank you.

Answers (1)

Answers (1)

kunju1991
Participant
0 Likes

Issue: when you change the input box value the data in all the rows suddenly become same.

Suggestion: if my understanding is correct then shouldn't you check the change event of your input control. Can you check the code for the same.

Former Member
0 Likes

This is what I have in xml.

kunju1991
Participant
0 Likes

check the live change methods "onLiveChangeBatch" and "onLiveChangePostingQuantity"

Former Member
0 Likes

For now those methods are empty, because I am getting the same data issue.