0

i have a strange problem with pagination.

I have an ng-controller getting data from JSON array populated by Web Service collecting date from database. When i add a new elemnt in database and update JSON data, i don't see this update reflected on the view. To avoid this i had to refer the JSON array by named controller. Now i see the view updated after the db update and JSON data refresh, but pagination is not working anymore, i see all the data expanded without any pagination (before i had 5 items per page).

I'm using blur admin template, based on bootstrap.

This is my html code, i had to introduce "BPC" as prefix for my list of data "ServiceCallList".

<tr ng-repeat="item in BPC.ServiceCallList">
        <td class="table-id">{{item.callID}}</td>
        <td class="table-id">{{item.subject}}</td>
        <!--<td class="table-id">{{item.customer}}</td>
        <td class="table-id">{{item.custmrName}}</td>-->
        <td class="table-id">{{item.itemCode}}</td>
        <!--<td class="table-id">{{item.itemName}}</td>-->
        <td class="table-id">{{item.internalSN}}</td>
        <!--<td class="table-id">{{item.manufSN}}</td>-->
        <!--<td class="table-id">{{item.contractID}}</td>-->
        <td class="table-id">{{item.createDate | date:'dd-MM-yyyy'}}</td>
        <td class="table-id">{{item.AssignDate | date:'dd-MM-yyyy'}}</td>

        <!--data-toggle="modal" ng-click="open('app/pages/ui/modals/modalTemplates/basicModal.html', 'md')"-->
        <!--<td class="table-id"><button class="status-button btn btn-xs btn-info" ui-sref="servicecall({callID: item.callID, isNew: false})">INFO</button></td>-->
        <td class="table-id"><button class="status-button btn btn-xs btn-info" data-toggle="modal" ng-click="showmodal(item)">VIEW</button></td>
    </tr>
    <tfoot>
        <tr>
            <td colspan="11" class="text-center">
                <!--<pagination items-per-page="BPC.pageSize" ng-model="BPC.currentPage" max-size="5" class="pagination-sm"></pagination>-->
                    <div st-pagination="" st-items-by-page="5" st-displayed-pages="5"></div>
            </td>
        </tr>
    </tfoot>

In my controller I had to do this

var BPC = this;
BPC.ServiceCallList = [];

And my function to load ServiceCallList is this

// Carica chiamate di servizio per il cliente selezionato
    loadGenericList($scope.CardCode, 'SERVICECALLS', $scope.docType).then(
        function (response) {
            $scope.dataLoading = true;
            $scope.documentsData = response;

            angular.forEach($scope.documentsData, function (value) {
                BPC.ServiceCallList.push(value);
            });                
        }         
    );

I think that could be something related to the scope, but cant' figure out what could be.

Thanks for any help.

npiccone
  • 21
  • 2

1 Answers1

0

You need to add st-safe-src="BPC.tablecollection" as well as st-table="BPC.ServiceCallList"

<table st-safe-src="objectDataArr[0]" st-table="BPC.ServiceCallList">

source: Client side pagination not working in smart table

also if st-pipe used, Check this https://github.com/lorenzofox3/Smart-Table/issues/207

Community
  • 1
  • 1
Manoj.jsm
  • 138
  • 1
  • 6
  • Hi, I tried to add the st-safe-src to my HTML code, in this way but what i get is that pagination correctly display in table footer (with the right number of pages), but items are not paginated, they are still showed. Also the aspect of my table has been messed up.
    – npiccone Aug 22 '16 at 15:12
  • 1
    OK, Manoj, i got it working!...You pointed me in the right direction! – npiccone Aug 22 '16 at 15:23