https://github.com/lwfwind/spring-jquery-datatable
Spring extension to work with the great jQuery plugin DataTables (http://datatables.net/)
https://github.com/lwfwind/spring-jquery-datatable
datatable datatables spring spring-jquery-datatable
Last synced: 5 months ago
JSON representation
Spring extension to work with the great jQuery plugin DataTables (http://datatables.net/)
- Host: GitHub
- URL: https://github.com/lwfwind/spring-jquery-datatable
- Owner: lwfwind
- Created: 2016-09-30T08:00:14.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-20T07:34:35.000Z (over 9 years ago)
- Last Synced: 2025-07-07T06:50:41.250Z (12 months ago)
- Topics: datatable, datatables, spring, spring-jquery-datatable
- Language: Java
- Size: 75.2 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# spring-jquery-datatable
This project is an extension of the Spring project to ease its use with jQuery plugin [DataTables](http://datatables.net/) with **server-side processing enabled**.
This will allow you to handle the Ajax requests sent by DataTables for each draw of the information on the page (i.e. when paging, ordering, searching, etc.) from Spring **@Controller**.
## Example:
#### On the server-side
```java
@Controller
@RequestMapping(value = "/pc")
public class PCController {
@Autowired
private PCActionService pcActionService;
@RequestMapping(value = "/get_pc_tea_api_action")
@ResponseBody
public DatatablesResponse findPCTeaAPIActionsWithDatatablesCriterias(HttpServletRequest request) {
DatatablesCriterias criterias = DatatablesCriterias.getFromRequest(request);
DataSet actions = pcActionService.findPCTeaAPIActionsWithDatatablesCriterias(criterias);
return DatatablesResponse.build(actions, criterias);
}
}
```
```java
@Service
public class PCActionServiceImpl implements PCActionService {
@PersistenceContext
private EntityManager entityManager;
@Override
public DataSet findPCTeaAPIActionsWithDatatablesCriterias(DatatablesCriterias criterias) {
TableQuery query = new TableQuery(entityManager, PCTeaAPIAction.class, criterias);
return query.getResultDataSet();
}
}
```
#### On the client-side
On the client-side, you can now define your table loading data dynamically :
```javascript
$(document).ready(function() {
var table = $('#teaPCApiActionTable').DataTable({
processing: true,
serverSide: true,
columns: [
{"data": "time"},
{"data": "uid"},
{"data": "api_name"},
{"data": "request_type"},
{"data": "parameters"},
{"data": "response_idx"}
],
ajax: {
url: '/pc/get_pc_tea_api_action',
type: 'GET'
}
});
}
```
## Maven dependency
```xml
com.github.lwfwind.web
spring-jquery-datatable
3.2
```