Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Row grouping using Server side = true with Ajax Post method not working #1699

Unanswered
Ankitapatelit asked this question in Q&A
Discussion options

I am using below data table option in Angular application. I want to achieve Row grouping like this example using below code. https://datatables.net/examples/advanced_init/row_grouping.html . But it doesn't do row group. Any help is appreciated. Thank you.

Type Script:
var groupColumn = 1;

this.dtOptions = {
serverSide: true,
processing: true,
dom: 'QBfrtip',
drawCallback: function (settings: any) {
var api = this.api();
var rows = api.rows({ page: 'current' }).nodes();
var last: any = null;
api.column(groupColumn, { page: 'current' })
.data()
.each(function (group: string, i: number) {
if (last !== group) {
$(rows).eq(i).before('' + group + '');
last = group;
}
});
},
ajax: (dataTablesParameters: any, callback: any) => {
that.http
.post(
'https://xtlncifojk.eu07.qoddiapp.com/',
dataTablesParameters, {}
).subscribe(resp => {
that.persons = resp.data;
callback({
recordsTotal: resp.recordsTotal,
recordsFiltered: resp.recordsFiltered,
data: []
});
});
},
columns: [ { data: 'id' }, { data: 'firstName' }, { data: 'lastName' }]
};

HTML:

ID First name Last name
{{ person.id }} {{ person.firstName }} {{ person.lastName }}
No data!
You must be logged in to vote

Replies: 1 comment

Comment options

Hi,

This is because your ajax callback's data property is empty. This indicates to datatables library that there is no data to render.

Please look at Angular Pipes or TemplateRef example in the documentation for recommended way.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.