com.github.lwfwind.web:spring-jquery-datatable

Spring extension to work with the great jQuery plugin DataTables

License

License

Categories

Categories

Data
GroupId

GroupId

com.github.lwfwind.web
ArtifactId

ArtifactId

spring-jquery-datatable
Last Version

Last Version

3.2
Release Date

Release Date

Type

Type

jar
Description

Description

Spring extension to work with the great jQuery plugin DataTables
Project URL

Project URL

https://github.com/lwfwind/spring-jquery-datatable
Source Code Management

Source Code Management

https://github.com/lwfwind/spring-jquery-datatable

Download spring-jquery-datatable

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.lwfwind.web/spring-jquery-datatable/ -->
<dependency>
    <groupId>com.github.lwfwind.web</groupId>
    <artifactId>spring-jquery-datatable</artifactId>
    <version>3.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.lwfwind.web/spring-jquery-datatable/
implementation 'com.github.lwfwind.web:spring-jquery-datatable:3.2'
// https://jarcasting.com/artifacts/com.github.lwfwind.web/spring-jquery-datatable/
implementation ("com.github.lwfwind.web:spring-jquery-datatable:3.2")
'com.github.lwfwind.web:spring-jquery-datatable:jar:3.2'
<dependency org="com.github.lwfwind.web" name="spring-jquery-datatable" rev="3.2">
  <artifact name="spring-jquery-datatable" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.lwfwind.web', module='spring-jquery-datatable', version='3.2')
)
libraryDependencies += "com.github.lwfwind.web" % "spring-jquery-datatable" % "3.2"
[com.github.lwfwind.web/spring-jquery-datatable "3.2"]

Dependencies

compile (7)

Group / Artifact Type Version
log4j : log4j jar 1.2.16
com.github.lwfwind.common : java-common-helper jar 1.3
org.apache.tomcat.embed : tomcat-embed-core jar 8.5.5
org.hibernate.javax.persistence : hibernate-jpa-2.1-api jar 1.0.0.Final
org.apache.poi : poi-ooxml jar 3.8
org.apache.poi : poi-scratchpad jar 3.8
org.springframework : spring-webmvc jar 4.3.2.RELEASE

Project Modules

There are no modules declared in this project.

spring-jquery-datatable

This project is an extension of the Spring project to ease its use with jQuery plugin DataTables 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

@Controller
@RequestMapping(value = "/pc")
public class PCController {

    @Autowired
    private PCActionService pcActionService;

    @RequestMapping(value = "/get_pc_tea_api_action")
    @ResponseBody
    public DatatablesResponse<PCTeaAPIAction> findPCTeaAPIActionsWithDatatablesCriterias(HttpServletRequest request) {
        DatatablesCriterias criterias = DatatablesCriterias.getFromRequest(request);
        DataSet<PCTeaAPIAction> actions = pcActionService.findPCTeaAPIActionsWithDatatablesCriterias(criterias);
        return DatatablesResponse.build(actions, criterias);
    }
}
@Service
public class PCActionServiceImpl implements PCActionService {
    @PersistenceContext
    private EntityManager entityManager;

    @Override
    public DataSet<PCTeaAPIAction> 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 :

$(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

<dependency>
    <groupId>com.github.lwfwind.web</groupId>
    <artifactId>spring-jquery-datatable</artifactId>
    <version>3.2</version>
</dependency>

Versions

Version
3.2
3.1
3.0
2.9
2.8
2.7
2.6
2.5
2.4
2.3
2.2
2.1
2.0
1.9
1.8
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1.0