Home > other >  Having trouble on searching on a table, pagination type... It only search a record on the current pa
Having trouble on searching on a table, pagination type... It only search a record on the current pa

Time:09-22

Having trouble on searching on a table, pagination type... It only search a record on the current page, but cannot search a record onto the next page.

I've tried parent and child method from angular.io

had try codes from another component which having a table, cannot applied it though

$scope.ViewUserinfoBFAR = function (page) {
        var pageIndex = 0;
        if (page == undefined) {
            pageIndex = 0;
        } else {
            pageIndex = page - 1;
        }
        $scope.bfarInformation = [];
        userinformationService.viewAllUserInfo().then(function (res) {
            console.log(res)
            // userinformationService.viewUserInfo("usertype=FELIS,"   $scope.searchSecond   "regionId="   $scope.regionId   "&userrole=Administrator,Evaluator,Endorser,Cashier,recommendingApprover,evaluator,administrator,cashier,endorser,records,recommendingofficer,recommendingapproval,approval,approver&page="   pageIndex   "&size=10").then(function (res) {
            // console.log("BFAR", res);
            // $scope.currentActivePageBFAR = res.number   1;
            // $scope.numRowPerPageBFAR = res.size;
            // $scope.maxPaginateSizeBFAR = 10;
            // $scope.totalDataRowBFAR = res.totalElements;
            // $scope.bfarInformation = res.content;

            // $scope.bfarInformation = res.filter(obj => (obj.regionId == $scope.regionId));
            $scope.bfarInformation = res.filter(obj => obj.lastName && obj.region && obj.regionId != null);
            //&& (obj.userrole.toLowerCase() == "administrator" || obj.userrole.toLowerCase() == "evaluator" || obj.userrole.toLowerCase() == "endorser" || obj.userrole.toLowerCase() == "cashier" || obj.userrole.toLowerCase() == "recommendingApprover" || obj.userrole.toLowerCase() == "records" || obj.userrole.toLowerCase() == "recommendingofficer" || obj.userrole.toLowerCase() == "recommendingapproval" || obj.userrole.toLowerCase() == "approval" || obj.userrole.toLowerCase() == "approver" || obj.userrole.toLowerCase() == "inspector")

            console.log($scope.bfarInformation)

            $scope.tableParamsBFAR = new NgTableParams({ sorting: { firstName: "asc" } }, {
                dataset: $scope.bfarInformation
            });
        }, function (e) { })
    }

CodePudding user response:

it is because your angular script have only the current page from api/backend so in the filter block you should pass the filter params to the backend to search throw the hole data then get the result and refresh the state with new data/result

  • Related