Home ag-grid Angular 10 ag-Grid Show Hide Columns

Angular 10 ag-Grid Show Hide Columns

by therichpost
9 comments
Angular 9, Angular 10

Hello to all, welcome to therichpost.com. In this post, I will tell you, Angular 10 ag-Grid Show Hide Columns.

Post Working:

In post, I am showing you, how to show hide columns in ag-grid on button click in angular 10 application.

Angular 10 came. If you are new in Angular 10, then please check below links:

Angular 10 Basics Tutorials

Angular 10 for Beginners


Here are the more posts related to ag-Grid:

  1. ag-Grid add new row
  2. ag-Grid delete row
  3. ag-Grid show hide columns
  4. ag-Grid open modal popup on row click

Working demo video that I have made few months ago.

Here are also some posts related to Angular ag-Grid:

Add ag-Grid in Angular application

Open Modal PopUp row click event on ag-Grid in Angular application


Now below is the code snippet for add new row ag-Grid:

1. Very first, you need to implement below tutorial link steps for adding ag-Grid into your angular 10 application:

Implement ag-Grid into Angular 10

2. Add below code into your app.component.ts file:

...
import { AgGridAngular } from "ag-grid-angular";

export class AppComponent {

....

  @ViewChild('agGrid') agGrid: AgGridAngular;
  
  HideModel()
	{
	  this.agGrid.columnApi.setColumnsVisible(['model'], false);
	  this.agGrid.api.sizeColumnsToFit();
 
	}
  ShowModel()
	{
	  this.agGrid.columnApi.setColumnsVisible(['model'], true);
	  this.agGrid.api.sizeColumnsToFit();
 
	}



}

3. Now add below code into your app.component.html file:

<button class="btn btn-success mr-2 mb-2"  (click)="ShowModel()">Show Model</button>
<button class="btn btn-warning mr-2 mb-2" (click)="HideModel()">Hide Model</button>
<ag-grid-angular
    style="height: 300px;" 
    class="ag-theme-balham-dark"
    [rowData]="rowData"
  #agGrid
    [columnDefs]="columnDefs"
    rowSelection="multiple"
    >
</ag-grid-angular>

This is it and if you have any kind of query then please comment below.

Note: First, you have to implement this https://therichpost.com/angular-9-10-ag-grid-working-example/ and after this you can get this post working easily:

Jassa

Thanks

You may also like

9 comments

Ismal July 14, 2020 - 6:09 pm

sir when camera video submitted to mysql video available

Reply
Ajay Malhotra July 15, 2020 - 2:57 pm

Very soon.

Reply
Ismal July 15, 2020 - 9:05 pm

this week?

Reply
AhmedBila July 15, 2020 - 2:14 pm

Is this ur full time job or just hobby? or both? regards boss!

Reply
Ajay Malhotra July 15, 2020 - 2:56 pm

This is my passion.

Reply
Jegan Saminathan July 17, 2020 - 5:23 am

Hi Ajay,

I have a custom header components to delete a column. So we can achive on that. Ie from child to parent communication. Also I dont see the complete code of your video.

Thanks
jegan

Reply
Ajay Malhotra July 17, 2020 - 7:57 am

Can you make your requirement bit more clear?
Thanks

Reply
kalanthar October 29, 2020 - 9:17 am

can we use it on low version of angular

Reply
Ajay Malhotra October 29, 2020 - 9:19 am

yes.

Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.