Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
183 views
Welcome To Ask or Share your Answers For Others

1 Answer

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...