0

Im displaying 2 data in one cell with ag-grid but i want the data to be with break line not like this : Data without break line

i tried to use "\n" "\r" "\br" but didnt work. here is my code :

    import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Grid, GridApi } from 'ag-grid-community';
import { AgGridAngular } from 'ag-grid-angular';
import { DealsService } from './services/deals.service';
import * as moment from 'moment';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
title = 'app';

columnDefs = [
{headerName: 'Class', cellRenderer: function(params){ return params.data.DEALCAT + params.data.DEALID},width:150, filter: true} ,

];

rowData : any;
constructor(private service:DealsService) {



}
dateFormatter(params){
return moment(params.value).format('DD/MM/YYYY');
}

ngOnInit() {
this.service.getDealsList().subscribe(data => {
this.rowData = data;
}); }

}

and here is the code html :

<ag-grid-angular class="ag-theme-balham" ng-grid="gridOptions"
style="width: 1350px; height: 630px;"
class="ag-theme-alpine"
[rowData]="rowData"
[columnDefs]="columnDefs"

[animateRows]="true"
[paginationPageSize]="10"
[pagination]="true"
>
</ag-grid-angular>
Abaoub
  • 71
  • 10
  • 1
    Does this answer your question? [AG-Grid - How to insert a line break into my cell data](https://stackoverflow.com/questions/49038923/ag-grid-how-to-insert-a-line-break-into-my-cell-data) – shutsman May 30 '20 at 11:42
  • Thank you for help. but where i should place rowHeight in gridOptions to make the '
    works because when i just put '
    the second value dont appear i guess because of the auto-height of the cell which is 25px so i need to change the height but i don't know how to do that. – Abaoub just now Edit
    – Abaoub May 31 '20 at 16:32

1 Answers1

2

Try like this

cellRenderer: function(param){
    return param.data.DEALCAT + '<br/>' + param.data.DEALID;
  }
vinothvs
  • 1,224
  • 1
  • 10
  • 17