Your search did not match any results.
Data Grid

Record Paging

The DataGrid splits records into multiple pages. This technique helps optimize control performance: the client only needs to load and render one page at a time. Users can use a scroll bar or a pager to navigate between pages. This demo shows how to enable and customize the pager.

The pager is configured in the pager object and contains the following elements:

  • Page navigator
    Enables page navigation.

  • Page size selector
    Changes the page size. To display this element, enable the showPageSizeSelector property. You can also define the allowedPageSizes and specify the initial pageSize in the paging object.

  • Page information
    Displays the current page number and total record count. To display page information, enable the showInfo property. You can also use the infoText property to customize the information text string.

The pager supports full, compact, and adaptive (default) display modes. In compact mode, the pager hides page information and changes the appearance of other elements to use screen space more efficiently. In adaptive mode, the pager automatically chooses between the full and compact modes based on the DataGrid's width. Use the displayMode property to switch between modes.

In this demo, you can use the drop-down Display Mode menu to switch between full and compact display modes. You can also use the checkboxes to hide or display different pager elements. Note that when the pager is in compact mode, navigation buttons are always visible but page information is hidden.

Copy to CodePen
Apply
Reset
var DemoApp = angular.module('DemoApp', ['dx']); DemoApp.controller('DemoController', function DemoController($scope) { $scope.dataGridOptions = { dataSource: generateData(100000), keyExpr: 'id', showBorders: true, customizeColumns: function(columns) { columns[0].width = 70; }, scrolling: { rowRenderingMode: 'virtual' }, paging: { pageSize: 10 }, pager: { visible: true, allowedPageSizes: [5, 10, 'all'], showPageSizeSelector: true, showInfo: true, showNavigationButtons: true }, onInitialized: function(e) { $scope.dataGrid = e.component; } }; $scope.displayModeOptions = { items: [{ text: "Display Mode 'full'", value: "full" }, { text: "Display Mode 'compact'", value: "compact" }], displayExpr: "text", valueExpr: "value", value: "full", onValueChanged: function(data) { $scope.dataGrid.option("pager.displayMode", data.value); $scope.pageInfo.option("disabled", data.value === "compact"); $scope.navButtons.option("disabled", data.value === "compact"); } }; $scope.showPageSizesOptions = { text: "Show Page Size Selector", value: true, onValueChanged: function(data) { $scope.dataGrid.option("pager.showPageSizeSelector", data.value); } }; $scope.showInfoOptions = { text: "Show Info Text", value: true, onValueChanged: function(data) { $scope.dataGrid.option("pager.showInfo", data.value); }, onInitialized: function(e) { $scope.pageInfo = e.component; } }; $scope.showNavButtonsOptions = { text: "Show Navigation Buttons", value: true, onValueChanged: function(data) { $scope.dataGrid.option("pager.showNavigationButtons", data.value); }, onInitialized: function(e) { $scope.navButtons = e.component; } }; });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/21.1.4/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/21.1.4/css/dx.light.css" /> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js"></script> <script>window.angular || document.write(decodeURIComponent('%3Cscript src="js/angular.min.js"%3E%3C/script%3E'))</script> <script src="https://cdn3.devexpress.com/jslib/21.1.4/js/dx.all.js"></script> <script src="data.js"></script> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container" ng-app="DemoApp" ng-controller="DemoController"> <div id="gridContainer" dx-data-grid="dataGridOptions"></div> <div class="options"> <div class="caption">Options</div> <div class="option-container"> <div class="option"> <div id="displayMode" dx-select-box="displayModeOptions"></div> </div> <div class="option"> <div id="showPageSizes" dx-check-box="showPageSizesOptions"></div> </div> <div class="option"> <div id="showInfo" dx-check-box="showInfoOptions"></div> </div> <div class="option"> <div id="showNavButtons" dx-check-box="showNavButtonsOptions"></div> </div> </div> </div> </div> </body> </html>
#gridContainer { max-height: 800px; } .options { margin-top: 20px; padding: 20px; background-color: rgba(191, 191, 191, 0.15); position: relative; } .caption { font-size: 18px; font-weight: 500; } .option-container { display: flex; margin: 0 auto; justify-content: space-between; } .option { margin-top: 10px; display: flex; align-items: center; } .option-caption { white-space: nowrap; margin: 0 8px; }
let s = 123456789; function random() { s = (1103515245 * s + 12345) % 2147483647; return s % (10 - 1); } function generateData(count) { let i; const surnames = ['Smith', 'Johnson', 'Brown', 'Taylor', 'Anderson', 'Harris', 'Clark', 'Allen', 'Scott', 'Carter']; const names = ['James', 'John', 'Robert', 'Christopher', 'George', 'Mary', 'Nancy', 'Sandra', 'Michelle', 'Betty']; const gender = ['Male', 'Female']; const items = []; const startBirthDate = Date.parse('1/1/1975'); const endBirthDate = Date.parse('1/1/1992'); for(i = 0; i < count; i++) { const birthDate = new Date(startBirthDate + Math.floor( random() * (endBirthDate - startBirthDate) / 10)); birthDate.setHours(12); const nameIndex = random(); const item = { id: i + 1, firstName: names[nameIndex], lastName: surnames[random()], gender: gender[Math.floor(nameIndex / 5)], birthDate: birthDate }; items.push(item); } return items; }