3
I am working on a system that requires data pagination, but before I would like to sort the json I receive in the order of users' names.
JSON is in format:
[["22","Aiolinhos","23","[email protected]","Administradores","SIM"],["20","Aiorinhos","21","[email protected]","Administradores","SIM"],["6","Aldebas","7","[email protected]","Administradores","SIM"],["12","Caminhus","13","[email protected]","Administradores","SIM"],["18","Ditinho","19","[email protected]","Administradores","SIM"],["3","Dohkinho","3","[email protected]","Administradores","SIM"],["8","Kanonzinho","9","[email protected]","Administradores","SIM"],["14","Milinho","15","[email protected]","Administradores","SIM"],["4","Muzinho","4","[email protected]","Administradores","SIM"],["2","Saguinha","2","[email protected]","Administradores","SIM"],["1","Shakinha","1","[email protected]","Administradores","SIM"],["16","Shionzinho","17","[email protected]","Administradores","SIM"],["10","Shurinha","11","[email protected]","Administradores","SIM"]]
And the html+angular snippets I created to show this data to the user are:
<div class="container">
<div class="jumbotron">
<div class="row">
<div class="col-xs-12 text-right">
<button type="button" class="btn btn-secondary" ng-click="create()">Novo</button>
</div>
</div>
<table class="table table-hover">
<thead>
<tr>
<td ng-repeat="header in headers track by $index">{{header}}</td>
<td ng-if="headers.length">Editar / Remover</td>
</tr>
</thead>
<tr ng-repeat="row in rows | orderBy:order track by $index">
<td ng-repeat="cell in row track by $index" ng-if="!$first">{{cell}}</td>
<td ng-if="row.length"><button type="button" class="btn btn-secondary glyphicon glyphicon-pencil" ng-click="edit(row)"></button>
<button type="button" class="btn btn-danger glyphicon glyphicon-trash" ng-click="delete(row)"></button></td>
</tr>
</table>
</div>
</div>
controller:function($scope,$routeParams,$location,crudservice){
$scope.headers = [];
$scope.rows = [[]];
$scope.modelPath = $routeParams.model;
$scope.order = 0;
crudservice.model = {};
crudservice.listModel($routeParams.model).then(function(response){
if(response.data.status == 1){
var data = response.data;
console.log(JSON.parse(data.headers));
console.log(JSON.parse(data.rows));
$scope.headers = JSON.parse(data.headers);
$scope.rows = JSON.parse(data.rows);
}
});
But it turns out that the table does not show some lines, besides the cells Name, E-mail, Group, Assets and Edit/Remove are in places that should not:
Any assumptions as to why this is happening?
thanks for answering. So I found the point where I was missing. In my Usuariorestcontroller class where I was manipulating the view data, I was mapping the json header with an extra field, and the view was "expecting" an extra field. I believe that’s what you quoted, a wrong map manipulation.
– Alessandra
Ah, yes - in a second moment, you can notice this effect in the screenshot you posted. I’m glad you found the problem, @Alessandra!
– OnoSendai