akveo / ng2-smart-table

Angular Smart Data Table component
https://akveo.github.io/ng2-smart-table/
MIT License
1.63k stars 875 forks source link

Table not work when I refresh page #1337

Closed shaimaaezo closed 1 year ago

shaimaaezo commented 1 year ago

Hi, this issue appears when I come to refresh page component, this is my code => this.settings = { mode: 'internal', actions: { title: data['Action'], add: false, delete: false, }, edit: { editButtonContent: '', }, columns: { code: { title: data['creditLimitCode'], type: 'string', }, name: { title: data['creditLimitName'], type: 'string', }, days: { title: data['creditLimitDays'], type: 'string', }, discount: { title: data['creditLimitDiscount'], type: 'string', }, } }


<ng2-smart-table class="creditlimit-smart-table" [settings]="settings" [source]="source" (edit)="onEdit($event)">


::ng-deep .creditlimit-smart-table { .form-control { color: nb-theme(form-control-color); } }

h
javapach commented 1 year ago

this was happening to me too, but you need to declare and set your settings as a global variable:

@Component({
  selector: "yourComponent",
  templateUrl: "./yourComponent.component.html",
  styleUrls: ["./yourComponent.component.scss"],
})

export class yourNameComponent{

globalVariable1: any;
globalVariable2: any;
globalVariableN: any;

// declare your seettings here as global
 settings = {
    columns: {...},
    mode: 'internal',
   actions:{...}
  ....
  };

  constructor(){ ... }
}
shaimaaezo commented 1 year ago

this was happening to me too, but you need to declare and set your settings as a global variable:

@Component({
  selector: "yourComponent",
  templateUrl: "./yourComponent.component.html",
  styleUrls: ["./yourComponent.component.scss"],
})

export class yourNameComponent{

globalVariable1: any;
globalVariable2: any;
globalVariableN: any;

// declare your seettings here as global
 settings = {
    columns: {...},
    mode: 'internal',
   actions:{...}
  ....
  };

  constructor(){ ... }
}

thank you very much, its work