Best way to get only modified rows from observableArray (when there is bulk edit option)

后端 未结 2 1505
感动是毒
感动是毒 2021-02-10 05:58

I have an ObservableArray collection which binds to the HTML table with bulk edit option (MVC3), every time the user hits commit I wanted to send only the modified

2条回答
  •  清酒与你
    2021-02-10 06:23

    Here is a post about creating a dirty flag in Knockout that will track changes to all observables in an object.

    Typically, you would add a dirty flag to each item in your array in a constructor function or loop through each item and add the flag. Then, you can create a computed observable to represent just the changed items for sending back to the server.

    Here is a sample that shows a dirty flag on each item and a computed observable that contains only the dirty items: http://jsfiddle.net/rniemeyer/wauwn/

提交回复
热议问题