question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pagination doesn't work with custom data from json file

See original GitHub issue

I am using custom data from .json file and want to paginate the data but all data comes in single page ; why so? below are my code

 $http.get('app/user_keys.json').success(function(data) {
            vm.data = data;
            vm.tableParams = new NgTableParams({ page: 1, count: 2 }, {
                    total: vm.data.length,
                    getData: function (params) {
                        console.log(vm.data.length);
                        var deferred = $q.defer();
                        var orderedData = params.sorting() ? $filter('orderBy')(vm.data, params.orderBy()) : vm.data;
                        deferred.resolve(orderedData.slice((params.page() - 1) * params.count(),  params.page() * params.count()));
                    }
                });
        });
<table ng-table="vm.tableParams" class="table table-striped" >
                    <colgroup>
                          <col width="5%"/>
                          <col width="30%"/>
                          <col width="50%"/>
                          <col width="15%"/>
                    </colgroup>
                    <tr ng-repeat="row in vm.data | filter: searchText  track by $index">
                        <td header="'headerCheckbox.html'">
                        <input type="checkbox" value="row._id" ng-model="vm.checkboxes.items[row._id]" ></td>
                        <td data-title="'ID'">{{ row.index }}</td>
                        <td data-title="'Cloud Location'">{{ row.location }}</td>
                        <td data-title="'Action'"><i class="fa fa-trash"></i></td>
                    </tr>
                </table>

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:3
  • Comments:10

github_iconTop GitHub Comments

4reactions
miparnisaricommented, Dec 21, 2016

Ok I fixed it, it’s because dataOptions may be undefined. So the code should be

 if (settings.dataOptions && !settings.dataOptions.applyPaging) {
   return ngTableDefaultGetData(result, params);
 }
1reaction
fsm3xpertcommented, Aug 11, 2016

I’ve same problem, when paging on group data. So, i add these lines at the end on getGroups function.

if (!settings.dataOptions.applyPaging) {
    return ngTableDefaultGetData(result, params);
}
return ngTableDefaultGetData.applyPaging(result, params);

The pagination working on either used default or custom.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom data source property dataSrc and pagination issue
SOLUTION. Set parameters draw , recordsTotal and recordsFiltered as top-level properties of JSON response where DataTables expects them to be.
Read more >
Pagination issue using datatables, JSON url datasource, Jquery
Hi I am using JQUERY to load a JSON url data using Server side processing. The issue I am having is that, all...
Read more >
Ajax (remote data) - The jQuery replacement for select boxes
Select2 supports pagination ("infinite scrolling") for remote data sources out of the box. To use this feature, your remote data source must be...
Read more >
The List Component - React-admin - Marmelab
Default layout components ( <Datagrid> and <SimpleList> ) return null when the data is loading. If you use a custom layout component instead,...
Read more >
Database: Pagination - The PHP Framework For Web Artisans
This is done so that the paginator knows how many pages of records there are in total. However, if you do not plan...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found