diff --git a/samples/demos/ivs-people-register/Controllers/ODataController.cs b/samples/demos/ivs-people-register/Controllers/ODataController.cs index 602be96099..0c7aacbe0b 100644 --- a/samples/demos/ivs-people-register/Controllers/ODataController.cs +++ b/samples/demos/ivs-people-register/Controllers/ODataController.cs @@ -52,7 +52,7 @@ public string Metadata() public async Task People() { await this - .ODataHandler(tableSpec, this.pipe, ODataHandler.Metadata.MINIMAL) + .OData(tableSpec, this.pipe, ODataHandler.Metadata.MINIMAL) .OnError(ex => Response.Body.Write(Encoding.UTF8.GetBytes(ex.Message), 0, (ex.Message).Length)) .Get(); } diff --git a/samples/demos/ivs-people-register/Controllers/PeopleController.cs b/samples/demos/ivs-people-register/Controllers/PeopleController.cs index 14b7f9dc52..2474833cb9 100644 --- a/samples/demos/ivs-people-register/Controllers/PeopleController.cs +++ b/samples/demos/ivs-people-register/Controllers/PeopleController.cs @@ -1,6 +1,7 @@ using Belgrade.SqlClient; using Microsoft.AspNetCore.Mvc; using SqlServerRestApi; +using System.Text; using System.Threading.Tasks; // For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 @@ -38,7 +39,7 @@ public async Task OData() { Response.ContentType = "application/json"; await this - .ODataHandler(tableSpec, pipe) + .OData(tableSpec, pipe) .Process(); } @@ -52,7 +53,8 @@ await this public async Task Get() { await this - .JQueryDataTablesHandler(tableSpec, pipe) + .JQueryDataTables(tableSpec, pipe) + .OnError(ex => Response.Body.Write(Encoding.UTF8.GetBytes(ex.Message), 0, ex.Message.Length)) .Process(); } } diff --git a/samples/demos/ivs-people-register/project.json b/samples/demos/ivs-people-register/project.json index 777e6d0473..1795a7247a 100644 --- a/samples/demos/ivs-people-register/project.json +++ b/samples/demos/ivs-people-register/project.json @@ -16,7 +16,7 @@ "Microsoft.Extensions.Logging.Console": "1.0.0", "Microsoft.Extensions.Logging.Debug": "1.0.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", - "Sql-Server-Rest-Api": "0.3.1" + "Sql-Server-Rest-Api": "0.3.3" }, "tools": { diff --git a/samples/demos/ivs-people-register/wwwroot/media/js/lib/jquery.dataTables.incremental_pagination.js b/samples/demos/ivs-people-register/wwwroot/media/js/lib/simple_incremental_bootstrap.js similarity index 62% rename from samples/demos/ivs-people-register/wwwroot/media/js/lib/jquery.dataTables.incremental_pagination.js rename to samples/demos/ivs-people-register/wwwroot/media/js/lib/simple_incremental_bootstrap.js index 17436bef3c..5f14ae49de 100644 --- a/samples/demos/ivs-people-register/wwwroot/media/js/lib/jquery.dataTables.incremental_pagination.js +++ b/samples/demos/ivs-people-register/wwwroot/media/js/lib/simple_incremental_bootstrap.js @@ -1,12 +1,58 @@ -$.fn.dataTableExt.oPagination.incremental = { - /* - * Function: oPagination.incremental.fnInit - * Purpose: Initalise dom elements required for pagination with a list of the pages - * Returns: - - * Inputs: object:oSettings - dataTables settings object - * node:nPaging - the DIV which contains this pagination control - * function:fnCallbackDraw - draw function which must be called on update - */ +/** + * This pagination style shows Previous/Next buttons, and page numbers only + * for "known" pages that are visited at least once time using [Next>] button. + * Initially only Prev/Next buttons are shown (Prev is initially disabled). + * + * [] + * + * When user navigates through the pages using [Next>] button, navigation shows + * the numbers for the previous pages. As an example, when user reaches page 2, + * page numbers 1 and 2 are shown: + * + * [] + * + * When user reaches page 4, page numbers 1, 2, 3, and 4 are shown: + * + * [] + * + * When user navigates back, pagination will remember the last page number + * he reached and the numbesr up to the last known page are shown. As an example, + * when user returns to the page 2, page numbers 1, 2, 3, and 4 are still shown: + * + * [] + * + * This pagination style is designed for users who will not directly jump to + * the random page that they have not opened before. Assumption is that users + * will discover new pages using [Next>] button. This pagination enables users + * to easily go back and forth to any page that they discovered. + * + * Key benefit: This pagination supports usual pagination pattern and does not + * require server to return total count of items just to calculate last page and + * all numbers. This migh be huge performance benefit because server does not + * need to execute two queries in server-side processing mode: + * - One to get the records that will be shown on the current page, + * - Second to get the total count just to calculate full pagination. + * + * Without second query, page load time might be 2x faster, especially in cases + * when server can quickly get top 100 records, but it would need to scan entire + * database table just to calculate the total count and position of the last + * page. This pagination style is reasonable trade-off between simple and fullnumbers + * pagination. + * + * @name Simple Incremental navigation (Bootstrap) + * @summary Shows forward/back buttons and all known page numbers. + * @author [Jovan Popovic](http://github.com/JocaPC) + * + * @example + * $(document).ready(function() { + * $('#example').dataTable( { + * "pagingType": "simple_incremental_bootstrap" + * } ); + * } ); + */ + +$.fn.dataTableExt.oPagination.simple_incremental_bootstrap = { + "fnInit": function (oSettings, nPaging, fnCallbackDraw) { $(nPaging).prepend($("
    ")); var ul = $("ul", $(nPaging)); @@ -21,7 +67,6 @@ nFirst.className = "paginate_button first active"; nPrevious.className = "paginate_button previous"; nNext.className = "paginate_button next"; - ul.append(nPrevious); ul.append(nFirst); @@ -64,9 +109,8 @@ }, /* - * Function: oPagination.incremental.fnUpdate + * Function: oPagination.simple_incremental_bootstrap.fnUpdate * Purpose: Update the list of page buttons shows - * Returns: - * Inputs: object:oSettings - dataTables settings object * function:fnCallbackDraw - draw function which must be called on update */ @@ -107,4 +151,4 @@ } } } -}; +}; \ No newline at end of file diff --git a/samples/demos/ivs-people-register/wwwroot/server.html b/samples/demos/ivs-people-register/wwwroot/server.html index a65c863018..679ccf62ae 100644 --- a/samples/demos/ivs-people-register/wwwroot/server.html +++ b/samples/demos/ivs-people-register/wwwroot/server.html @@ -17,7 +17,7 @@ - +