We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

i want to show/hide command column based on session storage in typescript

HI Team ,

I want to hide the command column based on session storage value in EJ1 ejgrid controls with typescript and web api.






Thanks,
Divakaran N

1 Reply

VN Vignesh Natarajan Syncfusion Team February 7, 2019 11:34 AM UTC

Hi Muthukumar, 
 
Thanks for contacting Syncfusion Support. 
 
Query: “ want to hide the command column based on session storage value in EJ1 ejgrid” 
 
We have checked your query and based on your requirement  we have get the value of session variable using window.sessionStorage and based on the variable value we have hide the columns using hideColumns() method of the Grid. You can change the session variable value while performing any actions based on your requirement. 
 
<script>  
    var value = window.sessionStorage.getItem('hideColumn'); 
    window.sessionStorage.setItem('hideColumn', true);   
 
</script> 
 
Grid.html:- 
 
<button class="btn btn-primary" (click)="hideColumn();" type="button">Hide Column</button> 
<ej-grid [allowPaging]="true" [allowSorting]="true" [dataSource]="gridData"> 
    <e-columns> 
        <e-column headerText="Manage Records" width="75" textAlign="right"> 
        </e-column> 
</ej-grid> 
 
Grid.ts:- 
 
public gridData: any; 
     hideColumn() : any { 
       if(value=="true"){ 
        var obj = $("#ejControl_0").ejGrid("instance"); 
        obj.hideColumns("Manage Records"); 
       } 
     } 
constructor() 
{ 
    this.gridData = [{ 
        .  .     .  . 
   }]; 
} 
 
    
 
Refer our API documentation for you reference 
 
 
If we misunderstood your query, please get back to us with more details. 
 
Regards, 
Vignesh Natarajan  
 
 


Loader.
Live Chat Icon For mobile
Up arrow icon