0

I am using smart-table and I would like to get the value of displayedCollection in my controller.

<table id="oldUsersTable" st-table="displayedCollection" st-safe-src="allOldUsers" class="table table-striped">
<thead>
<tr>
    <th class="table-width-auto">{{'oldUsers.tableTh_selected' | translate}}</th>
    <th class="table-width-auto">{{'oldUsers.tableTh_firstName' | translate}}</th>
    <th class="table-width-auto">{{'oldUsers.tableTh_lastName' | translate}}</th>
</tr>
<tr>
    <th colspan="3">
        <input class="form-control width-max" placeholder="{{'common.searchPlaceholder' | translate}}"
               dom-search dom-search-timeout="800" dom-search-table-id="'oldUsersTable'" dom-search-page-size="pageSize"/>
    </th>
</tr>
</thead>
<tbody>
<tr class="oldUsersTableTr" ng-repeat="row in displayedCollection" ng-class="selectedUserClass(row)" ng-click="selectUser(row)">
    <td class="align-center">
        <checkbox model="row.selected" classes="'margin-left-right-auto'"></checkbox>
    </td>
    <td>
        {{row.firstName}}
    </td>
    <td>
        {{row.lastName}}
    </td>

    <td style="width: 100px !important; height: 50px;">
        <button class="btn btn-sm blue-steel oldUserDeleteButton" ng-click="deleteUser(row.uuid)">
            {{'oldUsers.deleteUser' | translate}}&nbsp;
            <i class="fa fa-trash-o"></i>
        </button>
    </td>
</tr>
</tbody>
<tfoot>
<tr>
    <td colspan="3" class="text-center">
        <div id="oldUsersPagination" st-pagination="" st-template="templates/fragments/smartTablePagination.html" st-items-by-page="pageSize" st-displayed-pages="10"></div>
    </td>
</tr>
</tfoot>

In the controller I have tried to get the displayedCollection using (in according to this comment https://stackoverflow.com/a/42073243/13057292): $scope.displayedCollection is undefined.

I have tried implementing this solution without success: https://stackoverflow.com/a/30294098/13057292

A Plunker with an example: http://plnkr.co/edit/DwYTmgaO2fiJjzap?preview

AngularJS v1.5 and smart-table v. 2.1.8

MoonStone
  • 13
  • 2
  • Hello MoonStone, welcome to SO! To receive great answers quickly you need to be as elaborate as you can: add more parts of your code, what you have tried so far, what you are trying to achieve, etc. To have a better grasp on asking good questions you can refer to: https://stackoverflow.com/help/how-to-ask – Andrew Adam Mar 13 '20 at 14:21
  • 1
    Hello Andrew, Thank you for your help. I have updated the question. I hope it is more clear now. – MoonStone Mar 16 '20 at 08:57

0 Answers0