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>

4
  • have you tried defining the display collection and passing that to attribute? That is the filtered data. See st-safe-src in docs Commented Aug 13, 2015 at 12:03
  • Yes, we have tried with display collection in ng-csv export method. But face same issue Commented Aug 13, 2015 at 12:23
  • create demo that replicates problem. If collections are set up properly should be simple to use the filtered display collection from scope Commented Aug 13, 2015 at 12:28
  • We have used "displayed" array collection for exporting Commented Aug 13, 2015 at 13:42

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.