4

We have implemented a report table using angular smart table.When user applied search criteria using st-search , we need to export all items into csv.We have used ng-csv directive for exporting. When use st-table array collection, the only first page data is getting.That mean total 7 records after filtering and first page showing 5 items, only this data(5 items) is exported.How can export all filtered data?

 <table class="table table-striped" st-table="displayed">
<thead>
<tr>
    <th  st-sort="firstName">first name</th>
    <th  st-sort="lastName">last name</th>
    <th  st-sort="birthDate">birth date</th>
    <th  st-sort="balance">balance</th>
    <th >email</th>
</tr>
<tr>
    <th>
        <input st-search="firstName" placeholder="search for firstname" class="input-sm form-control" type="search"/>
    </th>
    <th colspan="4">
        <input st-search placeholder="global search" class="input-sm form-control" type="search"/>
    </th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in displayed">
    <td>{{row.firstName | uppercase}}</td>
    <td>{{row.lastName}}</td>
    <td>{{row.birthDate | date}}</td>
    <td>{{row.balance | currency}}</td>
    <td><a ng-href="mailto:{{row.email}}">email</a></td>
</tr>
</tbody>
<tfoot>
        <tr>
            <td colspan="5" class="text-center">
                <div st-pagination="" st-items-by-page="5" st-displayed-pages="10"></div>
            </td>
        </tr>
    </tfoot>

Vipin RT
  • 298
  • 4
  • 16

1 Answers1

3

You can have access to the filtered collection through the table controller api. So you just need to create a directive which requires the stTable controller:

.directive('stExport',function(){
   return {
     require:'^stTable',
     link:function(scope, element, attr,ctrl){
       element.bind('click',function(){
       alert(ctrl.getFilteredCollection().length);
     })
   };
}

have a look at that running example

laurent
  • 2,590
  • 18
  • 26