on 04-26-2017 8:48 AM
Hi Experts,
I have done all for delete function in table row, but I'm getting error at removeItems.
Here is my code.
onDeletePress: function(sEvent){
var sDat = this.getView().byId("Table");
var sTabData = sEvent.getSource().getBindingContext().getObject();
var oMack = {};
oMack.TabData = sTabData;
sTabData.removeItems(oMack[0]);
},
please help me in this issue.
Thank you,
in Advance.
Regards,
Rock Well
Hi Rock Well,
instead of removing item try removing the data from the attached data to table and refreshing the model (better way)
I think you might be using the delete event of sap.m.Table (inherit from sap.m.ListBase). if its the delete event than checkout this even handling below :
onDeletePress : function(oEvent)
{
// getting the row data which you want to delete
var item = oEvent.getParameter("listItem").getBindingContext(<modelName if any >).getProperty();
// getting table data
var tableData = oEvent.getSource().getModel(<modelName if any>).getData();
//getting the index of the deleted item so as to remove from the table Data. id it the key of that record which will determine the record which needs to be deleted
var index = $.map(tableData,function(obj, index){if(obj.id === item.id){return index;}});
tableData.splice(index[0],1);
//refreshing the model with new data
var model = new sap.ui.model.json.JSONModel();
model.setData(tableData);
oEvent.getSource().setModel(model,"<modelName if any>");
}
thanks
Viplove
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
check below examples if helps.
delete single row: https://jsfiddle.net/Akhilesh_U/utxk76vx/
delete selected rows: https://jsfiddle.net/Akhilesh_U/bd91zshc/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.