How can I tailor the child count in ag grid to fit my needs?

Currently, I am using ag grid with React and have successfully implemented row grouping. However, the parent rows are displaying child row counts in numeric values. Is there a way to customize the style of the row count? Additionally, I am interested in calculating the total number of rows based on the values in the children rows.

I am relatively new to working with ag grid. Does anyone have a solution for this issue?

https://i.sstatic.net/SRbzl.jpg

https://i.sstatic.net/KQY9G.jpg

Answer №1

This could be the solution you've been searching for

https://www.example.com/grouping-group-rows

You'll need to disable group count and implement a custom renderer

main.js

import GroupInnerRenderer from './groupInnerRenderer.jsx'
// ...

const GridExample = () => {
  const groupRendererParams = useMemo(() => {
    return {
      innerRenderer: GroupInnerRenderer,
      suppressCount: true,
    }
  }, [])

  // ...

  return (
    <AgGridReact
      rowData={rowData}
      columnDefs={columnDefs}
      defaultColDef={defaultColDef}
      columnTypes={columnTypes}
      groupDisplayType={'groupRows'}
      groupRowRendererParams={groupRendererParams}
      onGridReady={onGridReady}
    />
  )
}

and create your GroupInnerRenderer

groupInnerRenderer.jsx

export default (props) => {
  // customize as needed
}

Further reading available at https://www.example.com/configuring-group-cell-renderer

UPDATE:

If you're short on time, check out this working Plunker: https://plnkr.co/plunk/xyz123

In the inner renderer component, calculate and set leafChildren. The data prop of each country's children contains what you need.

https://i.sstatic.net/image.png

FINAL UPDATE:

To reposition the expand icon, utilize a different approach: cellRenderer

cellRenderer.jsx

import React, { useCallback, useEffect, useState } from 'react'

export default (props) => {
  const { node, value } = props
  // implementation details here...
};

Apply it to the last column: Sport

{ field: 'sport', cellRenderer: CellRenderer },

Don't forget to remove the original expand icon in autoGroupColumnDef's cellRendererSelector parameter

const autoGroupColumnDef = useMemo(() => {
  return {
    headerName: 'Country',
    minWidth: 300,
    cellRendererSelector: (params) => {
      return
    },
  }
}, [])

https://i.sstatic.net/updated-image.png

Check out the revised Plunker here:

https://plnkr.co/plunk/qwerty

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

Loading content synchronously

Could you assist me in finding a solution to synchronize the loading of pages and elements? Currently, my code looks like this: $(Element).load(File); ... other commands... window.onload = function () { Update_Elements(Class, Content); } Everything ...

ReactJS encountered an error: _this3.onDismissID is not defined as a function

My goal is to retrieve the latest news related to a specific search term from a website, showcase them, and provide a dismiss button next to each news item for users to easily remove them if desired. Here's a snippet of the code I'm using: import ...

What is the best way to differentiate the handling of a 401 Unauthorized response from other errors within an Angular 8 service that utilizes RxJS?

My REST API implementation requires an access token for user identification with each call. If the token is missing or expired, the endpoint returns a 401 UNAUTHORIZED response. There are instances where I make API calls using a timer in my service class: ...

Perform a search using indexOf method on JSON.stringify objects

I am attempting to determine whether a specific string exists in the following code: var test1 = '{"packageId":"1","machineId":"1","operationType":"Download"},{"packageId":"2","machineId":"2","operationType":"Download"}'; alert("found: " + test1 ...

Inspecting Facebook links

Currently working on a website and interested in incorporating a feature similar to what Facebook has. I'm referring to the link inspector, but I'm not entirely sure if that's its official name. Allow me to provide an example to clarify my r ...

How can I show the unique phrase "Today" on a specific date (date=today) with the Angular-UI-Bootstrap Datepicker?

I'm currently integrating the Angular-UI datepicker directive into my project and I'm facing an issue. I want to have the datepicker display 'Today' instead of the actual date like 2015/04/27. Is there a way to achieve this without hav ...

What is the best way to manage a new Error in Node.js while utilizing ES6 Symbols?

In my node.js application, I am implementing an endpoint using ES6 Symbols. Here is an example: // ES6 Symbol Method const taskCreationMethod = { [Symbol.taskMethod]() { return { storeCheckFunc: async function(storeId, employeeId) ...

Struggling to configure an input field using ExtJS

I am trying to use an onChange event to update an input field with the selected option. Below is my code: HTML: <select id="builds" onchange="setBuild()"> <option value="select">Select</option> ... </select> <input ty ...

Stop processing the current websocket connection once a new websocket request is received

Currently, I am utilizing the npm ws module (or its wrapper named isomorphic-ws) for establishing a websocket connection. NPM Module: isomorphic-ws This setup allows me to retrieve an array of data from a websocket++ server situated on the same local mac ...

What is the process for creating a server-side API call?

I've designed a front-end application that uses an API to retrieve data. The problem I'm facing is that in order to access the API, I need to use an API Key. If I include the API key in the client-side code, it will be visible to users. How can I ...

Is there a way to populate rows in a data table on subsequent pages using JavaScript?

Here is the ajax function I have written to change values of a row on one page while updating the total on another page of my data table. $.ajax({ type : "Post", contentType : "application/json; charset= ...

One way to submit a value form in an iframe is by double clicking

I am looking to submit a value form in a frame that functions as described below: index.php <form action="iframe1.php" method="post" target="iframe1"> <input type="text" name="lala"> <input type="submit"> </form> <iframe name= ...

JavaScript scripts are unable to function within an Angular directive's template due to compatibility issues

I'm facing an issue with a directive (function (angular) { 'use strict'; function digest(factory) { var directive = { restrict: 'E', templateUrl: '/js/app/digest/templates/digest.tem ...

The Chrome equivalent of -moz-user-focus

We have a custom model dialog control that we use for all popups on our web pages. When this dialog is initialized, we use jQuery expose to gray out the rest of the page. To prevent selection on the grayed-out area, we apply the following styles to the mas ...

Is there a proper method for populating an HTML text with values from a form?

As a newcomer, I could really use some guidance here :) I'm trying to populate text with various words, numbers, and calculation results from a form. This is my initial attempt for just one field/word, and it appears to be functioning correctly. Do y ...

Having trouble with AutoCompleteExtender OnClientItemSelected not functioning in IE8 but working perfectly in IE9? Let's dive into the JavaScript substring

My AutoCompleteExtender is connected to a web service and works perfectly. The Target TextBox (tb_provider1) has autocomplete capabilities thanks to the GetProviders function. What I want to achieve is triggering a javascript function when a user selects a ...

I'm trying to integrate a chatbot into my website using Node-RED. Can someone guide me on how to utilize the Bluemix Tone Analyzer to analyze the tone of the user

Creating a chat bot to ask psychological questions and analyze how a person is feeling has been my recent project. I managed to set up a chat bot in Bluemix, following a tutorial on integrating it into Node Red: https://github.com/watson-developer-cloud/no ...

I am encountering a confusing issue where utilizing await does not actually wait for a Promise to resolve. Can you shed some light on why this unexpected behavior is happening?

Here is a function that I am working with: const getCurrentDetails= async () => { const currentDateTime = new Date(moment('00:00','HH:mm') .tz('America/New_York') ...

Struggling to extract specific data from a table using angular.js

My table includes Roman numerals (i.e. I, II, III, ......VIII) for filtering using Angular.js. However, I am facing an issue where the filtration process works for some values but not for others. Please review my code below: subject.html: <table cl ...

How can I quickly send a flash logout notification through Express or verify if a redirection has occurred

Hey everyone, I'm currently dealing with an issue in my server.js setup where I'm trying to display the message "logged out successfully" on the /login page when a user logs out. The problem stems from using multiple middleware and feeling overwh ...