Closed ncc0706 closed 5 years ago
I Solved it!
spring-data-jpa-datatables
@PostMapping(value = "guojini")
public DataTablesOutput<LandMerchantGuoJin> list(@RequestBody @Valid DataTablesInput input) {
return landMerchantGuojinRepository.findAll(input);
}
angular-datatables
ngOnInit() {
const that = this;
this.titleService.setTitle(this.title);
this.dtOptions = {
serverSide: true,
processing: true,
ajax: (dataTablesParameters: any, callback) => {
that.http
.post<DataTablesResponse>(
'http://localhost:8080/land/guojini',
dataTablesParameters, {}
).subscribe(resp => {
console.log(resp)
that.data = resp.data;
callback({
recordsTotal: resp.recordsTotal,
recordsFiltered: resp.recordsFiltered,
data: []
});
});
},
columns: [{ data: 'id' }, { data: 'name' }, { data: 'shortName' }]
};
}
https://l-lin.github.io/angular-datatables/#/basic/server-side-angular-way