How to remove grid column based on the flag

How to remove "Column1" if I set flag as true and add the column "Column1" when flag is set to false. 



1 Reply 1 reply marked as answer

RS Rajapandiyan Settu Syncfusion Team October 13, 2020 09:01 AM UTC

Hi Akshatha, 
  
Greetings from Syncfusion support.  

By using visible property of the Grid column, you can dynamically hide and show the column in the Grid. Refer to the below code example and sample for more information. 


App.component.html 

// column is hided at initial rendering 
 <e-column field='OrderID' headerText='Order ID' [visible]="!show" width='120' textAlign='Right'></e-column> 


App.component.ts 

click1(args){ 
      this.show = false; 
      this.grid.getColumnByField("OrderID").visible = !this.show;   // show the column in the Grid 
      this.grid.refreshColumns(); 
    } 
    click2(args){ 
      this.show = true; 
      this.grid.getColumnByField("OrderID").visible = !this.show;  // hide the column in the Grid 
      this.grid.refreshColumns(); 
    } 



Please get back to us if you need further assistance with this.  
  
Regards,  
Rajapandiyan S 


Marked as answer
Loader.
Up arrow icon