Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Ag-Grid not displaying correctly

I'm trying to use Angular Ag-Grid in my Web Application.

I've followed these tutorials

  1. Angular Grid | Get Started with ag-Grid

  2. ag-Grid Angular Component

Problem / Issue I Follwed every thing exactly. Even data is being loaded in grid but View is not very appreciable. Here what I'm getting (not alignment, no coloring) enter image description here

What I tried I search extensively over Google and Stack Overflow. Some Answers recommend that CSS is not loading Properly ( which is solid argument) but I double check my import statements on Component.css and Also tried adding .css reference in index.html. The .css files which I refer are exists and reference was also good.

What I Expect

enter image description here

Codes

appComponent.html

<ag-grid-angular style="width: 500px; height: 500px;" class="ag-theme-balham" [rowData]="rowData"
  [columnDefs]="columnDefs">
</ag-grid-angular>

appComponent.ts

import { Component } from '@angular/core';
import { Grid } from 'ag-grid/main';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {

  title = 'Grid1';
  columnDefs = [
    { headerName: "Make", field: "make" },
    { headerName: "Model", field: "model" },
    { headerName: "Price", field: "price" },
  ];

  rowData = [
    { make: "Toyota", model: "m1", price: 35351 },
    { make: "Ford", model: "m2", price: 6546 },
    { make: "M3", model: "m3", price: 646 },
    { make: "M765", model: "m4", price: 56486 }
  ]
}

app.component.scss

@import "~ag-grid/dist/styles/ag-grid.css";
@import "~ag-grid/dist/styles/ag-theme-balham.css";

I Also tried other tutorial which says this app.component.scss

@import "~ag-grid-community/dist/styles/ag-grid.css";
@import "~ag-grid-community/dist/styles/ag-theme-balham.css";
like image 822
Waseem Ahmad Naeem Avatar asked Sep 06 '19 09:09

Waseem Ahmad Naeem


People also ask

How do you refresh the grid on AG Grid?

Refresh Cells: api. refreshCells(cellRefreshParams) - Gets the grid to refresh all cells. Change detection will be used to refresh only cells who's display cell values are out of sync with the actual value. If using a cellRenderer with a refresh method, the refresh method will get called.

How do you get gridOptions on AG Grid?

Access the Grid & Column API You can access the APIs in the following ways: Store them from the gridReady event - they'll be available via the params argument passed into the event. Provide a gridOptions object to the grid pre-creation time. Post-creation the APIs will be available on the gridOptions object.

How many records can AG Grid handle?

The grid can handle massive amounts of data (100k+ rows). The grid will only render what's visible on the screen (40 rows approximately, depending on your screen size) even if you have thousands of rows returned from your server.

Is AG Grid part of Angular?

AG Grid is the industry standard for Angular Enterprise Applications. Developers using AG Grid are building applications that would not be possible if AG Grid did not exist. Please refer to our Compatibility Chart for Supported Versions of Angular & AG Grid.


1 Answers

Ag Grid styles should be imported in styles.scss not in app.component.scss

So try to import in styles.scss and check:

@import "~ag-grid-community/dist/styles/ag-grid.css";
@import "~ag-grid-community/dist/styles/ag-theme-balham.css";
like image 161
Uma Avatar answered Oct 20 '22 20:10

Uma