You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+15-8
Original file line number
Diff line number
Diff line change
@@ -116,16 +116,17 @@ First, you need to parse Request parameters using UriParser in order to extract
116
116
117
117
That's everything that you need to do. With three lines of code you can get OData service on any table.
118
118
119
-
120
119
## Implement REST service that process JQuery DataTables Ajax request
121
120
122
121
[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:
123
122
- 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.
125
124
126
125
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:
127
126
```
128
-
$('#mytable').DataTable({
127
+
$(document).ready(function() {
128
+
129
+
$('#example').DataTable( {
129
130
"serverSide": true,
130
131
"ajax": "/api/People",
131
132
"columns": [
@@ -134,10 +135,14 @@ $('#mytable').DataTable({
134
135
{ "data": "address", "width": "50%" },
135
136
{ "data": "town", "width": "10%" }
136
137
]
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:
141
146
```
142
147
IQueryPipe sqlQuery = null;
143
148
@@ -176,5 +181,7 @@ First, you need to parse Request parameters using UriParser in order to extract
[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/]
0 commit comments