4

I am using knockout.js to create jqgrid and populate the data using observableArray. (using Knockout-jqGridBinding plugin) Array for jqgrid data:

var initialData = [{
    id: ko.observable(1),
    name: ko.observable("Well-Travelled Kitten"),
    sales: ko.observable(352),
    price: ko.observable(75.95)
}];

function viewModel() {
    var self = this;
    self.items = ko.observableArray(result);
}
ko.applyBindings(new viewModel());

HTML

   <table>
     <tbody data-bind="foreach: items">
    <tr>
        <td><input data-bind="value: id"/></td>
        <td><input data-bind="value: name"/></td>
        <td><input data-bind="value: sales"/></td>
        <td><input data-bind="value: price"/></td>
    </tr>    
     </tbody>
   </table>
    <table id="items" data-bind="grid: { data: items }" >
    <thead> 
        <tr> 
        <th data-field="actions" style="width:27px;" data-sortable="false"></th>
        <th data-field="name" width="150px" data-editable="true">Item Name</th> 
        <th data-field="sales" data-editable="true">Sales Count</th> 
        <th data-field="price" data-editable="true">Price</th> 
        </tr> 
    </thead> 
    </table>

Now it populates the data in jqgrid and if I change data outside it reflects in grid as well but when I am changing the data in jqgrid using "cellEdit" it's not reflecting.

Shubh
  • 6,693
  • 9
  • 48
  • 83
Deepak K
  • 329
  • 3
  • 11
  • 1
    JQwidgets are giving same functionality which I want but it is paid. http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxknockout/grid.htm?fresh – Deepak K Jan 09 '13 at 01:52
  • 2
    Eventually I fixed this issue, I have again push the new data in array using "aftersavecell" event, this way every time observable array is updating. – Deepak K Mar 13 '13 at 13:03
  • 16
    you can add an answer to your own question, maybe with more details and code samples. – Davi Fiamenghi Feb 26 '14 at 19:59

0 Answers0