Manipulating Data in AG-GRID with AngularJS: A Guide to External Editing

Currently, I'm in the process of developing a single-page application that utilizes AngularJS, UI-Router, and AG-GRID. However, I've encountered an issue with updating AG-GRID's data from an external form.

Here is a breakdown of the problem: on the AG-GRID data table, I have implemented a button that extracts row data and transfers it to a separate form page. The form page successfully populates with the data. However, upon editing the data in the form and returning to the main page (where AG-GRID is located), the changes are not reflected.

I attempted using $scope.gridOptions.api.refreshCells(); but this command does not seem to work and does not produce any errors or results.

Thus far, this is how my setup is structured:

Main_controller:

App.controller('Main_Controller', function ($scope, $http, $filter, $timeout, $mdDialog, $q, $resource, $interval, $mdSidenav, $state, Service) {

    var Buttons = function(params) {
        return '<md-button class="md-icon-button" aria-label="Edit" ng-click="Edit(data)"> <md-icon class="material-icons">mode_edit</md-icon> </button>'';
    }

    var columnDefs = [
    { cellRenderer: Buttons, width: 165 },
    { headerName: "Data1", field: "Data1"},
    { headerName: "Data2", field: "Data2"}, 
    ];

    $scope.gridOptions_incident = {
        columnDefs: columnDefs,
        domLayout: 'autoHeight',
        enableFilter: true,
        enableColResize: true,
        enableSorting: true,
        pagination: true,
        paginationPageSize:25,
        animateRows: true,
        headerHeight: headerHeight,
        rowHeight:rowHeight,
        angularCompileRows : true,  
        enableCellChangeFlash: true,
        debug: true,
        rowData: Service.get_data()
    };  

    $scope.Edit = function(data){
        Service.current_incident(data);
        $state.go('OPEN_ExternalForm');
    };  

});

Service:

GDI_App.factory('Service', function($http, $q, $timeout, $mdDialog, $resource, $window) {
    return{

        get_data: function(){
            var example_data = [
               { "Data1": "123123", "Data2": "15437"  },
               { "Data1": "432234", "Data2": "146"  },
               { "Data1": "45654", "Data2": "3534"  },
               { "Data1": "76587", "Data2": "78978"  },
               { "Data1": "2342", "Data2": "5345878"  },
               { "Data1": "178", "Data2": "34534"  },
               { "Data1": "173838", "Data2": "354534"  },
            ];
            return example_data             
        }
        current_incident: function(data){
          Current.Data = data;
          return Current.Data
        }

    }
});

Form Controller:

GDI_App.controller('Form_Controller', function ($scope, $http, $filter, $timeout, $mdDialog, $q, $resource, $interval, $mdSidenav, Service) {

    $scope.Current.Data = Service.current_incident();
    $scope.Submit = function(){

        $http({
            method: 'POST',
            url: REST_URL,
            processData: false,
            contentType: "application/json;odata=verbose",                 
            headers: HEADER_DATA,
            data: $scope.Current.Data
        });   

    }

});

Form HTML:

The basic HTML form includes:
<div ng-controller="Form_Controller">
    Data1: <input ng-model="Current.Data.Data1">
    Data2: <input ng-model="Current.Data.Data2">
    <button ng-click="Submit()" type="button">Submit</button>
</div>

I am puzzled by what might be causing this issue. My ultimate objective is to allow for data editing from an external source and ensuring synchronization with AG-Grid.

Does anyone have any insights or suggestions?

Answer №1

To update cell information, simply follow these steps:

  var specificRow = $scope.gridOptions_incident.api.getRowNode(id);
  specificRow.setDataValue('Data2', 'newData');

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The phase does not appear to reset back to null

In my current project, we are working on a large-scale Angular application integrated with Ruby PageObject for testing. One issue we have encountered is that occasionally an $interval triggers the $digest cycle unexpectedly, resulting in unpredictable fail ...

Define the format for the output file name in TypeScript

I am trying to change the filename of a TypeScript generated js file. How can I accomplish this? For instance, I currently have MyCompany.ClassA.ts The default output filename is MyCompany.ClassA.js However, I would like the output filename to be MyComp ...

Strategies for ensuring a promise is fulfilled before moving on to the next iteration in a never-ending for loop in JavaScript

I've been exploring ways to ensure that a promise is resolved before moving on to the next iteration in a for loop. One suggestion was to use the setInterval() function instead of a for loop, but this isn't ideal since it's hard to predict w ...

Create automatic transcripts for videos, including subtitles and captions

Are there any tools or plugins available that can automatically create a transcript of a video for website playback? For example, generating captions and subtitles in the English language. ...

Managing array elements in React: removing and duplicating items

One of my tasks is to incorporate a copy and delete button within a table. My goal is to pass the index from the map to the delete and copy onclick functions, however, I am encountering an issue where copying a row results in it having the same index as th ...

typescript: best practices for typing key and value parameters in the forEach loop of Object.entries()

I have a specific object with key/value pairs that I need to iterate over using the entries() method of Object followed by a forEach() method of Array. However, I'm struggling to understand how to avoid a typescript error in this situation: type objTy ...

The Angular scope fails to reflect changes on the view

In this angular ng-click event, I have the following code: eventApp.controller('DetailEventController', ['$scope', '$http', '$compile', '$timeout', function ($scope, $http, $compile, $timeout, uiCalendarCon ...

Discovering the object and its parent within a series of nested arrays

Is there a way to locate an object and its parent object within a nested array of unknown size using either lodash or native JavaScript? The structure of the array could resemble something like this: name: 'Submodule122'</p> I have been ...

Understanding the concept of callbacks and scopes

While experimenting with the concept of callbacks, I encountered a scenario where I wanted to confirm that my understanding of the situation was correct. function greet(callback) { // 'greet' function utilizes a callback var greeting = "hi"; ...

Implementing jsGrid: Appending a row with JSON information

Is there a way to dynamically insert a row in jsGrid? I found some helpful code examples at https://github.com/tabalinas/jsgrid/blob/master/demos/db.js ...

Update the URL and content in Django dynamically

When accessing a json response from my Django backend via the URL /inbox/<str:username>, all messages in the conversation with that user are retrieved. The issue arises on the inbox page, where both threads and chatbox are displayed together, similar ...

Determine whether the browser is being used on an Android or iOS device

Is there a dependable method to alter buttons and text on a mobile site based on whether the user is using an Android or iOS browser? ...

appending a set of parameters to a website address

I am currently developing an app in a Node/Express/Jade environment. Imagine that I launch my app and navigate my browser to the following URL: /superadmin/?year=2012 Upon reaching this page, I encounter a list of objects sorted in a default order. Ther ...

How can I pass a value from JavaScript back to the .blade file in Laravel using DataTables?

I have some rows that are being displayed: The DataTable plugin within app.js is responsible for outputting each row. My goal is to target a specific value, ${row.category_id} let TABLE = $('#categoryList').DataTable({ { data: &ap ...

regular expression for replacing only alphanumeric strings

I'm currently developing a tool that tags alphanumeric words based on the option selected from the right-click context menu. However, I am facing issues when a group of words containing special characters is selected. I have been using the following ...

When using res.json(), the data is returned as res.data. However, trying to access the _id property within it will result

I'm facing a challenge in comprehending why when I make a res.json call in my application, it successfully sends data (an order object). However, when I attempt to access and assign a specific piece of that data (res.data._id) into a variable, it retu ...

Ensure that the folder name contains specific characters

When working with AngularJS, I am developing a feature to create folders. One requirement is that if a folder name contains special characters like /, :, ?, "<", or |, an error message should be displayed stating "A folder name cannot contain any of the ...

Tips for effectively highlighting search text within HTML content without causing any issues

I am in search of a solution that can assist me in searching for specific terms within an HTML string while also highlighting them. I have the ability to remove the HTML content from the string, but this poses the problem of losing the context of the origi ...

Having trouble displaying dynamically generated texture from a fragment shader in ThreeJS

I've been working on creating a texture using a Three.WebGLRenderTarget and then trying to access it in a fragment shader in the following stage. The concept is to execute the first stage once to generate a complex and costly SDF map, and then access ...

Display or conceal a frame with the help of JavaScript or jQuery

Is there a simple way to hide the "topFrame" and "menu" frames when clicking an image or button, and then unhide them by clicking again? Apologies for not including the "topFrame" and "menu" jsp files, as they are dynamically generated in my application. ...