Note that there are some explanatory texts on larger screens.

plurals
  1. POAngularJS and ng-grid - auto save data to the server after a cell was changed
    primarykey
    data
    text
    <p>My Use Case is pretty simple. A User, after editing a Cell (enableCellEdit: true), should have the data "automatically" sent to the server (on cell blur). I tried different approaches but none of them have properly worked out. I have a minimalistic grid:</p> <pre><code>// Configure ng-grid $scope.gridOptions = { data: 'questions', enableCellSelection: true, selectedItems: $scope.selectedRow, multiSelect: false, columnDefs: [ {field: 'id', displayName: 'Id'}, {field: 'name', displayName: 'Name'}, {field: 'answers[1].valuePercent', displayName: 'Rural', enableCellEdit: true} ] }; </code></pre> <p>For example, I tried to watch the data model passed to the Grid. But doing so won't return me the edited cell:</p> <pre><code>$scope.$watch('myData', function (foo) { // myModel.$update() }, true); </code></pre> <p>I tried to fiddle with the "ngGridEventData" data event but it does not fire after cell edit</p> <pre><code>$scope.$on('ngGridEventData', function (e, gridId) { // myModel.$update() }); </code></pre> <p>Finally, I tried to observer a Cell. However, this only work for a row by the mean of the "selectedCell" property of the grid:</p> <pre><code>$scope.selectedRow = []; $scope.gridOptions = { selectedItems: $scope.selectedRow, } $scope.$watch('selectedRow', function (foo) { console.log(foo) }, true); </code></pre> <p>Is it a <a href="https://github.com/angular-ui/ng-grid/wiki/Plugins" rel="noreferrer">ng-grid plugin</a> needed? I can't believe it is not something out of the box.</p> <p>Would you have a pointer / snippet how I could solve the auto save / send to the server?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload