cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with sap.ui.model.odata.v2.ODataListBinding#create

motiononme1
Participant
0 Kudos

Dear Expert,

I am refereing the SAP documentation to implement inline row creation in sap.ui.table.Table with OData V2 model, utilizing the create() method from the sap.ui.model.odata.v2.ODataListBinding library.

ODataListBinding#create

https://ui5.sap.com/#/topic/6c47b2b39db9404582994070ec3d57a2%23loio4c4cd99af9b14e08bb72470cc7cabff4

As per document i am getting the Rows context for the table and trying to use create() method. So, the entry is visible at the table without the need to first save it to the backend and then refresh the binding  but the create() method is not defined.

********************Code Start ************************************

<!-- sap.ui.table.Table control declared in XML view -->
<Table id="ToLineItems" rows="{
events : {createActivate : '.onCreateActivateLineItem'}
path : 'ToLineItems'
}">

// controller coding

// initial creation of inline creation rows when data has been loaded
onInit : function () {
var oItemsBinding = this.getView().byId("ToLineItems").getBinding("rows");

oItemsBinding.attachEvent("dataReceived", function () {
// check that length is final before creating at end and only create inactive entry once
if (oItemsBinding.isLengthFinal() && oItemsBinding.isFirstCreateAtEnd() === undefined) {
that.onCreateActivateLineItem();
}
});
},

// event handler for createActivate
onCreateActivateLineItem : function (oEvent) {
// product id is a required property for the item => item remains inactive if it's not set
if (!oEvent.getParameter("context").getProperty("ProductID")) {
oEvent.preventDefault();
return;
}

var oItemsBinding = this.getView().byId("ToLineItems").getBinding("rows");
oItemsBinding.create({/* initial data*/}, /*bAtEnd*/ true, {inactive : true});
}

**************************Code End *************************

Could you please provide any advice or suggestions?

Regards,

Sandeep

Accepted Solutions (1)

Accepted Solutions (1)

motiononme1
Participant
0 Kudos

Got the Solution.

  1. Issue: Not able to get create in sap.ui.model.odata.v2.ODataListBinding in SApUI5.
  2. Solution: create() in sap.ui.model.odata.v2.ODataListBinding is available from UI version 1.98.0, as i was using the old version, method was not available.

 

Answers (1)

Answers (1)

motiononme1
Participant
0 Kudos

Got the Solution

create() in sap.ui.model.odata.v2.ODataListBinding is available since 1.98.0 version, i was using older UI version.