Refill ag-grid with fresh data

Setting up the ag-grid initialization directly from the HTML using an onGridReady method in the component file.

<div style="flex-grow:1;">
    <ag-grid-angular

      style="float:left;width: 100%; height: 201px;margin-top:10px;"
      class="ag-theme-balham"
      [gridOptions]="gridOptions"
      [columnDefs]="columnDefs"
      (gridReady)="onGridReady($event)"
      [rowData]="rowData"
      #grid
    >
    </ag-grid-angular>
  </div>

In the corresponding .ts file, the onGridReady function is handled as follows:

onGridReady(params?: any) {
    console.log("onGridReady");
    var datasource = {
      getRows: (params: IGetRowsParams) => {
        this.info = "Getting datasource rows, start: " + params.startRow + ", end: " + params.endRow;
        console.log(this.info);
        this.getRowData().then(data => {
          if (this.stopApiCalls) {
            var lastRow = this.allTableData.length;
            params.successCallback(data, lastRow)
          }
          else {
            params.successCallback(data)
          }
        })
      }
    };
    console.log(">>",datasource);
    params.api.setDatasource(datasource);
  }

The this.getRowData function retrieves data from the backend service using HTTP.

Now, there is a need to reinitialize and trigger the onGridReady event based on a specific action taken in another component file. While methods in the ag-grid component can be accessed, the question arises on how to invoke the onGridReady event from this external component.

Answer №1

After the grid is initialized, the gridReady event occurs. If you want to access a dynamic component, it will necessitate a more intricate solution.

One potential workaround is to rerender the view using a router with dynamic parameters.

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

Checking for Object Equality in TypeScript

I'm working on a TypeScript vector library and encountered my first failed test. The issue revolves around object equality in TypeScript/JavaScript, and despite searching through TypeScript's official documentation (http://www.typescriptlang.org ...

The name 'console' could not be located

I am currently working with Angular2-Meteor and TypeScript within the Meteor framework version 1.3.2.4. When I utilize console.log('test'); on the server side, it functions as expected. However, I encountered a warning in my terminal: Cannot ...

Tips for tidying up duplicated typescript content sourced from a pre-existing library

Seeking guidance on implementing best practices and gaining a better understanding of my approach. After discovering the library react-google-calendar-api, I successfully installed it using npm in my React project. However, I wanted to expand its function ...

How do I incorporate global typings when adding type definitions to an npm module?

Suppose I create a node module called m. Later on, I decide to enhance it with Typescript typings. Luckily, the module only exports a single function, so the m.d.ts file is as follows: /// <reference path="./typings/globals/node/index.d.ts" /> decl ...

Navigating user profile routes effectively involves understanding the structure of the application

I'm currently working on developing a user-list feature that will display all users, along with user-detail components for each individual user. My main goal is to restrict access so that only administrators can see the complete list of users, while ...

Exploring the functionality of Array.prototype.includes() in Angular 7 with PhantomJS testing

While testing components in my Angular application, I noticed that unit tests utilizing Array.prototype.includes() are successful in Chrome but fail when executed with PhantomJS. I found some suggestions in the responses to this question related to a simi ...

Include a bank account for connecting to Stripe custom accounts

Currently, I am implementing Stripe Connect using Node.js and TypeScript for a platform that facilitates payments for third-party services referred to as "partners." Our decision to utilize Stripe Connect's custom accounts gives us complete control ov ...

Develop a FormGroup through the implementation of a reusable component structure

I am in need of creating multiple FormGroups with the same definition. To achieve this, I have set up a constant variable with the following structure: export const predefinedFormGroup = { 'field1': new FormControl(null, [Validators.required]) ...

Struggling to add phantom-js to my Angular project

I'm looking to incorporate the phantomJS library into my Angular 4 project for continuous integration with Jenkins. No matter what method I try, I keep encountering the same (or similar) error. For instance, when following this tutorial and attemptin ...

What is the process for installing both highcharts-angular and highcharts together?

UPDATE: Issue resolved - the problem was that the package.json file was read-only (refer to my answer). I have an Angular application (version 7) and I am attempting to integrate Highcharts. I am following the guidelines provided by highcharts-angular her ...

The Vue instance seems to be unable to recognize the shims-vue.d.ts file

I encountered an issue with my Vue file. Here is the code snippet: import Vue from 'vue'; import VueRouter from 'vue-router'; export default Vue.extend({ name: 'MyComponentsName', methods: { doRedirect() { this. ...

retrieving information and parsing from an API using Ionic and Angular version 4

How can I extract data from the "data" field in my API using a function? getMenu() { return this.http.get('http://site.dev/api/menu/7'); } { "id": 26, "name": "Default", "title": "default", "pageelements": [ { "id": 15, ...

Can we handle optional properties that are contingent on a boolean in the type?

My current scenario involves a server response containing a boolean indicating success and optional data or error information. type ServerResponse = { success: boolean; data?: { [key: string]: string }; err?: { code: number, message: string }; } Dea ...

How can Angular be used to create core styles in a CSS file rather than adding them dynamically within style tags?

Whenever I import a component, like MatTabsModule, it automatically generates styles within the head section: <style>.mdc-tab{min-width:90px;padding-right:24px....</style> I'd prefer to have all these styles generated in an external CSS f ...

What is the best way to integrate Sass into a Create-React-App project that is using TypeScript

After setting up a new project using create-react-app and typescript, I included a sass file in my project as per the documentation (which mentioned built-in support for sass files). However, when trying to compile, I encountered the following error relate ...

Leveraging IntersectionObserver to identify the video in view on the screen

Our Objective I aim to implement a swipe functionality for videos where the URL changes dynamically based on the ID of the currently displayed video. Challenges Faced Although I managed to achieve this with code, there is an issue where the screen flashe ...

Typescript: parameter must be included if another is also required

In the user interface, the parameter c is mandatory only if the parameter a is set to true. interface IArguments { a: boolean, b: string, c: string } The solution below seems to be effective, but how can I exclude the c parameter in the first scenar ...

The event fails to propagate up to the parent component

I have a project structure set up as follows: https://i.stack.imgur.com/bvmK5.jpg The todo-form component triggers the created event and I am looking to handle this event in the todos component. todo-form.component.html: <form class="todo-form" ( ...

Adjust the page URL during execution of a Protractor test

When conducting my protractor tests, I encountered a scenario where I needed to perform an action on page1 and then navigate to page2 in the same test script to verify the results. describe('something', function() { describe('foo', f ...

Leveraging Angular for Parsing JSON Data

I have a JSON object that I want to use in my code. The goal is to assign the values of certain properties from the JSON object to four variables in my Angular project. These variables are named as follows: authorText : string; titleText : string; duratio ...