How to update the rows of a table using dialog box

百般思念 提交于 2020-03-06 09:30:41

问题


I have been going through the below Plunker,

plunker link here

Here If I try to edit , the new record is added above instead of updating the current ,

How can I update the current edited row for the same example instead adding a new one?

  • I have tried deleting the row and update the new in the deleted place , but this idea is not correct tmk

Any guiding links or any help is much appreciated ....TIA


回答1:


From your code I understand you want to update the model (variable aData). It would be a better idea to use data binding but if you want to edit it you can use:

aData.map(function(item) { 
if (item.ID==id){
    item.Name = name;
    item.Age = age;
    item.Salary = sal;
}
return item; });

This is probably not the efficient way to do it and it consider you have unique ids. Also don't use the function unshift() because it add new value (doesn't update the existent).The record is added above because you actually add a new element (see link).




回答2:


You should try to work with data binding rather than manually extracting and inserting your values:

https://sapui5.hana.ondemand.com/1.28.33/docs/guide/91f0ca956f4d1014b6dd926db0e91070.html

Nevertheless, if you do want to edit a property of an item in your array, you can edit it as follows:

array[index].property = "new value";


来源:https://stackoverflow.com/questions/60166309/how-to-update-the-rows-of-a-table-using-dialog-box

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!