2

I'm new to Ag-grid(React version) and I encountered a problem in rendering multiple rows in a cell with Ag-Grid.

Here is what we've done by React Table but we want to do the same in the Ag-grid React version. What we have done by React Table

Does anyone know how can I do this?

I really appreciate your help.

1 Answer 1

2

Have a look at this documentation: Row Spanning Complex Example

You can use rowSpan property of ColDef while providing values for your ColDef. Provide rowSpan 1 for the two columns (2nd and 3rd visible in the screenshot), conditionally 1 or 2 for the 4th and 2 for the others.

colDef = [
  { field: 'field1', rowSpan: 2, /* other props */ },
  { field: 'field2', rowSpan: 1, /* other props */ },
  { field: 'field3', rowSpan: 1, /* other props */ },
  { field: 'field4', /* other props */, 
    rowSpan: (params) => {
      return  // your condition which decides rowSpan
    }
  },
  { field: 'field5', rowSpan: 2, /* other props */ },
  { field: 'field6', rowSpan: 2, /* other props */ }
];

Row spanning also has some limitations. Make sure you check this out as well: Constraints with Row Spanning

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.