akveo / ng2-smart-table

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

pager #757

Open HalaSalameh opened 6 years ago

HalaSalameh commented 6 years ago

why cant we dynamically change the settings?

AbelValdez commented 6 years ago

Hello HalaSalameh,

It is posible by using 2 ways.

First way: modifying the entery setting object I mean redefining

Second way: by creating a clone object of the settings object, then modify the cloned object and finally assining the memory reference to the original settings object. Example:

var clone = this.clone(this.settings);
clone.columns['new_col'] = {title: 'col_title'};
this.settings =  clone;
//clone function:
clone(obj) {
    if (null == obj || "object" != typeof obj) return obj;
    var copy = obj.constructor();
    for (var attr in obj) {
        if (obj.hasOwnProperty(attr)) copy[attr] = obj[attr];
    }
    return copy;
  }

reagrds!