floatingpurr
floatingpurr

Reputation: 8559

AngularJS: global search of Smart Table does not work with data loaded asynchronously

I'm using Smart Table for AngularJS but global search of Smart Table does not work with data loaded asynchronously. I made this little plnkr to see the problem in action.

Further details:

Accordingly to the doc, there are two copies of data, one is for the rendering while the other is the "static" safe copy of data. I have a table that displays data loaded via API. Here there is the table declaration in my HTML:

<table st-table="stc.displayedCollection" st-safe-src="stc.rowList" class="table table-striped">

As you can see, I'm telling smart table "who" are the two copies of my data.

Here there is the piece of controller to fetch data:

 stc.fetchData = function(val) {
      console.log(val);
      $http.get('data'+val+'.json').success(function(data){
          stc.rowList = data;
          stc.displayedCollection = [].concat(stc.rowList);
      });
  };

Once data are loaded, my smart table does not work fine (e.g. filter and sorting don't work).

Where is the problem?

Upvotes: 1

Views: 2640

Answers (1)

Rafael Zeffa
Rafael Zeffa

Reputation: 2414

i already had the same problem!!

you need to repeat the displayed collection instead the safe

 <table st-table="stc.displayedCollection" st-safe-src="stc.rowList>
   <tr ng-repeat="row in stc.displayedCollection">

Upvotes: 5

Related Questions