Please phone back regarding the adjustment of column sizes

Are there any callbacks provided for column resizing in ag-Grid?

I was unable to locate any documentation related to column resize callbacks.

Here is a sample code snippet:

var onColumnResized = function(params){
console.log(params);
};

gridOptions.onColumnResized = onColumnResized;
var myAgGrid = new agGrid.Grid(eGridDiv, gridOptions);

Answer №1

Grid Name : awesome-grid

Column Resizing Technique: To capture the column resize event, we can utilize the columnResized property in the grid configuration.

<ag-grid-angular
        class="ag-theme-alpine ag-grid-container-full"
        [rowData]="rowData"
        [columnDefs]="columnDefs"
        (gridReady)="onGridReady($event)"
        (columnResized)="onColumnResize($event)"  //  <-----
      >

In the associated TypeScript file: Since the resize event may be triggered multiple times, a debounce effect is implemented using setTimeout to handle it effectively.

   public setTimeInstance = null;

  onColumnResize(event) {

    if (this.setTimeInstance) clearTimeout(this.setTimeInstance);

    this.setTimeInstance = setTimeout(() => {

      let newColumnState = this.columnApi.getColumnState();

      this.someActivity();  // Perform some activity such as storage

      clearTimeout(this.setTimeInstance);


    }, 1000); // after one second

  }

Answer №3

One useful parameter indicates when all events have completed. Special thanks to @JobayerAhmmed for providing this helpful information.

onColumnResized(params) {
  if (params.source === 'uiColumnDragged' && params.finished) {
    this.gridApi.sizeColumnsToFit();
  }
}

<ag-grid-angular 
  #agGrid
  style="width: 100%; height: 100%;"
  class="ag-theme-balham"
  [columnDefs]="columnDefs"
  [rowData]="rowData"
  (gridReady)="onGridReady($event)"
  (columnResized)="onColumnResized($event)">
</ag-grid-angular>

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

Making JSON function in Internet Explorer

I'm encountering an issue retrieving data from a JSON feed specifically in Internet Explorer. Here's the problem. It functions correctly in Firefox, Chrome, and Safari, but fails to alert in IE: function perform_action(data){ alert(data); } ...

Trouble with Automatically Updating ObjectID in MongoDB using Node.js

My attempts to update the "ObjectId" from the front-end to my database have been unsuccessful. Adding new data from the UI works perfectly, but updating existing data does not. I've exhausted all options without success. Any assistance would be greatl ...

Using jQuery's .load() method to load a PHP file can result in an exponential increase in XHR finished loading time with each subsequent load

There seems to be an issue with my code using .load() to load a PHP page into a div whenever the navbar or link is clicked. After multiple clicks, I noticed that the "XHR finished loading" increases exponentially and it appears that the same PHP file is be ...

Is there a way to overlay a 'secret' grid on top of a canvas that features a background image?

I am currently working on developing an HTML/JS turn-based game, where I have implemented a canvas element using JavaScript. The canvas has a repeated background image to resemble a 10x10 squared board. However, I want to overlay a grid on top of it so tha ...

Condition in SQL for searching full name with no specific order of first name or last name

How can I search for a column named fullname by filtering on firstname/lastname without specific order? In the following Javascript example, the query is invalid when searching by lastname: function getQuery(searchWord){ return `SELECT * FROM user WHERE ...

Use JavaScript to swap out images

How can I change the image arrow when it is clicked? Currently, I have this code snippet: http://codepen.io/anon/pen/qEMLxq. However, when the image is clicked, it changes but does not hide. <a id="Boton1" class="button" onClick="showHide()" href="j ...

Is it the same item in one situation, but a completely different item in another?

I am currently investigating the behavior of objects in JavaScript, particularly when it comes to copying one object onto another. It seems that sometimes they behave as if they are the same object, where modifying one also modifies the other. Many resourc ...

Error: The function getAuth has not been defined - Firebase

I have included the code snippets from index.html and index.js for reference. The analytics functionality seems to be working fine, but I am facing an issue with authentication due to an error during testing. Thank you for your help. index.html <script ...

(Critical) Comparing AJAX GET Requests and HTTP GET Requests: identifying the true client

When a typical GET request is made through the browser, it can be said that the browser acts as the client. However, who exactly serves as the client in the case of a GET request via AJAX? Although it still occurs within the browser, I am intrigued to delv ...

Navigating through uncharted paths on Express

I am completely lost app.js app.use('/', userRoutes); app.use('/adminID', adminRoutes); app.all('*', (req, res, next) => { next(new AppError(`URL Not Found ${req.originalUrl}`, 404)); }) const ErrorHandler = require(' ...

The code encountered an error because it was unable to access the property 'style' of an undefined element on line 13 of the script

Why is it not recognizing styles and showing an error? All paths seem correct, styles and scripts are connected, but it's either not reading them at all (styles) or displaying an error. Here is the html, javascript, css code. How can this error be fix ...

Using Javascript to locate elements using xpath and cssSelector

My background primarily lies in Java/Selenium, where I typically use syntax like... By loginButton = By.xpath("//a[text(), 'Login']"); When it comes to JavaScript, what would the equivalent syntax be? Would it look something like this.. var lo ...

Executing Ajax calls following the selection of a box in a Python Bokeh plot

Two plots, plot1 and plot2, are available. The BoxSelectTool is enabled for plot2, allowing me to retrieve point coordinates from the selected rectangular area using CustomJS. My objective now is to initiate an ajax call with the acquired coordinates to ...

Angular 4: Triggering a function by clicking a link with specific parameters

I am relatively new to working with Angular 4. I have an anchor tag that, when clicked, should redirect me to a link where I also need to pass parameters. I'm unsure if my current approach is correct or not. Above all, I really need guidance on how to ...

Nest Js file uploads encountering issues when used in conjunction with JavaScript FormData functionality

I'm encountering some difficulties in parsing a request sent from the front-end using FormData. Below is an example request generated from Postman for Axios in node.js. Interestingly, when I use the same request in the Postman app, it functions as int ...

As I embark on building my web application using next.js, I begin by importing firebase from the "firebase" package. Unfortunately, a particular error unexpectedly surfaces in the terminal

I am currently developing a next.js web application and I have decided to utilize firebase for both database management and authentication. However, when attempting to import firebase in a specific file, I encountered the following error: Error - ./firebas ...

Error in ReactJs production code: ReferenceError - the process is undefined

Having some trouble with my ReactJs production code not recognizing environment variables. The error message reads: Uncaught ReferenceError: process is not defined <anonymous> webpack://testProject/./src/agent.js?:9 js http://localhost:8080/s ...

What are some effective strategies for reducing excessive re-rendering of React components?

Here is how I am displaying a list of components on the screen: const MessagesContainer = ({ messages, categories, addHandler }) => { const options = categories.map(category => ( { value: category.name, label: category.name } )); ...

What is the best way to send a POST request with an array containing multiple objects within it?

Unique Context Currently, I am expanding my knowledge of JavaScript by working on a REST API project using node.JS and express. I have encountered a challenge while attempting to parse an array of objects that contains nested arrays of objects. Below is a ...

Endless Invocation of Promise Functions in NodeJS

Searching for a way to endlessly call functions with promises. Experimented with 2 scenarios, one successful and the other not so much. The goal of the code that failed is to retrieve data from an API and store it in a database. Currently learning about p ...