Skip to content

Commit 865e676

Browse files
committed
readme update
1 parent 435001d commit 865e676

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

README.md

+15-8
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,17 @@ First, you need to parse Request parameters using UriParser in order to extract
116116

117117
That's everything that you need to do. With three lines of code you can get OData service on any table.
118118

119-
120119
## Implement REST service that process JQuery DataTables Ajax request
121120

122121
[JQuery DataTables](https://datatables.net/) is JQuery component that enhances HTML tables and adds rich client-side functionalities such as filtering, pagination, ordering by columns, etc. JQuery DataTables component might work in two modes:
123122
- Client-side mode where rows are loaded into the table in browser, and then all sorting, filering and pagination operations are done via JavaScript.
124-
- Server-side mode where AJAX request with informaiton about the curent page, sort/filter condition, is sent to the server, and REST API should return results that should be shown in the table.
123+
- [Server-side mode](https://datatables.net/examples/data_sources/server_side.html) where AJAX request with information about the curent page, sort/filter condition, is sent to the server, and REST API should return results that should be shown in the table.
125124

126125
In order to configure JQuery DataTables in server-side processing mode, you need to put an empty HTML table in your HTML page, and specify that DataTables plugin should be applied on this page with the following options:
127126
```
128-
$('#mytable').DataTable({
127+
$(document).ready(function() {
128+
129+
$('#example').DataTable( {
129130
"serverSide": true,
130131
"ajax": "/api/People",
131132
"columns": [
@@ -134,10 +135,14 @@ $('#mytable').DataTable({
134135
{ "data": "address", "width": "50%" },
135136
{ "data": "town", "width": "10%" }
136137
]
137-
});
138-
```
139-
Option "serverSide" will tell DataTables plugin to send AJAX request to the service that will return results that should be shown. Url of the service is defined in "ajax" option. The last option is list of the columns that shoudl be shown.
140-
To implement REST service that handles AJAX requests that JQuery DataTables sends in server-side mode, you would need to add the TableSpec object that describes the structure of the table that will be queried (name and columns). An example is shown in the following code:
138+
} );
139+
140+
} );
141+
```
142+
Option "serverSide" will tell DataTables plugin to send AJAX request to the service that will return results that should be shown. Url of the service is defined in "ajax" option.
143+
The last option is list of the columns that should be shown. This library supports [object data source](https://datatables.net/examples/ajax/objects.html), so columns property is requied.
144+
145+
In order to implement REST service that handles AJAX requests that JQuery DataTables sends in server-side mode, you would need to add the TableSpec object that describes the structure of the table that will be queried (name and columns). An example is shown in the following code:
141146
```
142147
IQueryPipe sqlQuery = null;
143148
@@ -176,5 +181,7 @@ First, you need to parse Request parameters using UriParser in order to extract
176181
await Response.Body.WriteAsync(System.Text.Encoding.UTF8.GetBytes("}"), 0, 1);
177182
}
178183
```
179-
[JQuery DataTables](https://datatables.net/) component requires AJAX response in some pre-defined format, so you woudl need to wrap results from database with header that contains number of total and number of filtered records.
184+
[JQuery DataTables](https://datatables.net/) component requires AJAX response in some pre-defined format, so you would need to wrap results from database with header that contains number of total and number of filtered records.
185+
Note that JQuery DataTables plugin uses **recordsTotal** and **recordsFiltered** to build pagination. Since you would need two additional queries . Reccomendation is to use alternative (paging plugins)[https://datatables.net/plug-ins/pagination/]
186+
that don't require these options.
180187

0 commit comments

Comments
 (0)