Search code examples
javascriptangularjsangularionic-frameworkngx-datatable

Hide column in ngx-datatable Ionic


I'm new to NGX-datatable. I have to populate my data table from Firebase in my ionic app. Given below is the format of JSON which is returned from the Firebase.

I want to know if I don't use the User_id as a column, how do I access the User_id in the row button click event? Or in the other hand, how can I use the User_Id as a column how to hide User_Id column. How can I achieve this?

{
User_id:data,
User_name:data
}

Solution

  • You can find here on how to toggle columns in ngx-datatable

    toggle(col) {
        const isChecked = this.isChecked(col);
        if(isChecked) {
          this.columns = this.columns.filter(c => { 
            return c.name !== col.name; 
          });
        } else {
          this.columns = [...this.columns, col];
        }
      }
    

    GITHUB DEMO