Forums - C# Corner

Forum guidelines
Nagarajan Elumalai

Nagarajan Elumalai

  • 1.7k
  • 130
  • 2.7k

Jquery Datatable Row Grouping from 2 different table

May 20 2019 12:52 AM
Hi Team,
 
I have below datatable. From this table i want to do row grouping.
I have to take Title column and should start the grouping. But the first value of the row should be a header remaining rows should come as grouping.
 
In this table  red colour text are coming from List 1. And yellow highlighted values are coming from list 2. Now i want to perform groupingg based on red colour title but grouping should be apply only on yellow highlighted.
 
Please help me on this.  
 
**Current Datatable:**
 
Title      Comments
12344   Demo policy data
12344   Demo data for 12344
12344   Test data for 12344
12344   Tested data for 123443
12345   TestPolicy1
12345   Test data 12345
12345   Demo data
12345   Test record added
12346   12346 data
12347   Test data added
Showing 1 to 10 of 10 entriesPrevious1Next
 
**Actual Table I am expecting:**
 
Title   Comments
12344   Demo policy data
12344   Demo data for 12344
12344   Test data for 12344
12344   Tested data for 123443
12345   TestPolicy1
12345   Test data 12345
12345   Demo data
12345   Test record added
12346   12346 data
12347   Test data added
Showing 1 to 10 of 10 entriesPrevious1Next
 
Code:
 
$pnp.sp.web.lists.getByTitle("TestPolicyNo").items.select("Title","PolicyName").top(5000).get().then(function(results) {
var uniquepolicynumber= new Set();
for (var i = 0; i < results.length; i++)
{
dataTable = $("#table_id").DataTable();
dataTable.row.add([results[i].Title,results[i].PolicyName]).draw(false);
$pnp.sp.web.lists.getByTitle("Testattachment").items.select("Title","Attachmentno").top(5000).filter("Title eq '"+results[i].Title+"'").get().then(function(attachmentscount) {
for( j=0; j
dataTable.row.add([attachmentscount[j].Title,attachmentscount[j].Attachmentno]).draw(false);
}
});
}
});
$("#table_id").dataTable({ "bLengthChange": false, "bPaginate": false}).rowGrouping({iGroupingColumnIndex: 0,
iGroupingColumnIndex2: 1,
bExpandableGrouping: true,
bExpandableGrouping2: true,
bExpandSingleGroup: false,
iExpandGroupOffset: -2,
sGroupingColumnSortDirection: "asc",
});

Answers (1)