Skip to Content
0
Former Member
Jun 24, 2015 at 11:05 AM

AttachDelete event in sap.m.table raising multiple times

63 Views

Hi all,

i am using sap.m table i am attaching attachDelete for table like below

oTable.setMode(sap.m.ListMode.Delete);

oTable.attachDelete(function(oEvent){

debugger;

var oSelectedItem = oEvent.getParameter("listItem");

var path = oEvent.getParameter('listItem').getBindingContext().sPath;

var obj = oTable.getModel().getProperty(path);

console.log(obj); // here is the object ot be deleted

var delrowId = oSelectedItem.getBindingContext().sPath.slice(oSelectedItem.getBindingContext().sPath.lastIndexOf('/')+1);

var objstr = JSON.stringify(obj);

oTable.getModel().getData().rows.splice(parseInt(delrowId), 1);

oTable.removeItem(oEvent.getParameter('listItem'));

amlvalues =sap.ui.getCore().getModel('mainModel').oData.MaintenanceLevels;

for(var i=0;i<amlvalues.length;i++)

{

if(JSON.stringify(amlvalues[i]) === objstr){

if(amlvalues[i].Updkz==='I'){

sap.ui.getCore().getModel('mainModel').oData.MaintenanceLevels.splice(i,1);

console.log(Index);

}else{

amlvalues[i].Updkz = 'D';

}}

}

});

attach delete event raising if i am clicking one delete icon it will raise multiple times and den deleting all rows followed by the delted row.

Thanks,

Kotesh.