0
votes

Please help. I'm currently developing a single page app using durandal, breeze, requirejs and knockout. The challenge i'm encountering right now is how to update an existing record that i selected from knockout grid. I've been reading through the documents and samples of breeze but all of them seems to have been created first as new entity then updated.

1
Can you paste some of your codeArmand

1 Answers

0
votes

Without any code from your side have a look at this.

What you need to remember about breeze is it tracks all changes to your entities, so basically once you have loaded your data from breeze all changes made in JavaScript will be tracked, so if you make any changes to the data and call the save method of breeze it will check the data for changes and if there are any changes it will call the server side save method.

var ViewModel = function(){
    var self = this;
    self.data = ko.observableArray(); //This data is loaded using breeze
    self.edit = function(item){
        //This needs to open the item in a modal or something where you can change the values, I usually do these things in a modal, can help more if I see your code.
    };
    self.save = function(){
        //Call breeze save method
    };
}

ko.applyBindings(new ViewModel());

So if your HTML looks like this:

<table data-bind="foreach: data">
    <tr data-bind="click: $root.edit">
        <td> Some data binding here </td>
    </tr>
</table>

Once done with the editing call the $root.save function