UNPKG

jqwidgets-framework

Version:

jQWidgets is an advanced Angular, Vue, Blazor, React, Web Components, jquery, ASP .NET MVC, Custom Elements and HTML5 UI framework.

92 lines (87 loc) 4.46 kB
<!DOCTYPE html> <html lang="en"> <head> <title id="Description">Grouping and Server Paging with jqxDataTable</title> <meta name="description" content="This sample demonstrates how we can implement Grouping and Server Paging with a Javascript DataTable"> <link rel="stylesheet" href="../../../jqwidgets/styles/jqx.base.css" type="text/css" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1 minimum-scale=1" /> <script type="text/javascript" src="../../../scripts/jquery-1.12.4.min.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxdatatable.js"></script> <script type="text/javascript" src="../../../scripts/demos.js"></script> <script type="text/javascript"> $(document).ready(function () { // prepare the data var source = { dataType: "json", dataFields: [ { name: 'ShipCountry', type: 'string' }, { name: 'ShipCity', type: 'string' }, { name: 'ShipAddress', type: 'string' }, { name: 'ShipName', type: 'string' }, { name: 'Freight', type: 'number' }, { name: 'ShippedDate', type: 'date' } ], root: 'value', url: "http://services.odata.org/V3/Northwind/Northwind.svc/Orders?$format=json&$callback=?" }; var dataAdapter = new $.jqx.dataAdapter(source, { formatData: function (data) { if (source.totalRecords) { // update the $skip and $top params of the OData service. // data.pagenum - page number starting from 0. // data.pagesize - page size data.$skip = data.pagenum * data.pagesize; data.$top = data.pagesize; data.$orderby = "ShipCountry asc"; } return data; }, downloadComplete: function (data, status, xhr) { if (!source.totalRecords) { source.totalRecords = data.value.length; } }, loadError: function (xhr, status, error) { throw new Error("http://services.odata.org: " + error.toString()); } } ); $("#dataTable").jqxDataTable( { width: getWidth("dataTable"), pageable: true, pagerButtonsCount: 10, serverProcessing: true, source: dataAdapter, altRows: true, groups: ['ShipCountry'], groupsRenderer: function(value, rowData, level) { return "Ship Country: " + value; }, columnsResize: true, columns: [ { text: 'Ship Name', dataField: 'ShipName', width: 250 }, { text: 'Ship Country', hidden: true, dataField: 'ShipCountry', width: 250 }, { text: 'Ship City', dataField: 'ShipCity', width: 150 }, { text: 'Ship Address', dataField: 'ShipAddress' } ] }); }); </script> </head> <body class='default'> <h3 style="font-size: 16px; font-family: Verdana;">Data Source: "http://services.odata.org"</h3> <div id="dataTable"></div> <div style="position: absolute; bottom: 5px; right: 5px;"> <a href="https://www.jqwidgets.com/" alt="https://www.jqwidgets.com/"><img alt="https://www.jqwidgets.com/" title="https://www.jqwidgets.com/" src="https://www.jqwidgets.com/wp-content/design/i/logo-jqwidgets.png"/></a> </div> </body> </html>