Rowgroups with enum sorting
Rowgroups with enum sorting
rossmere67
Posts: 3Questions: 1Answers: 0
Enum sorting works without rowgroup; must as soon as combine them I get an error that "A" is not a function. I know according to the rowgroup extension docs there are some limitations but I couldn't see custom sorting as one. Is this a bug?
$.fn.dataTable.enum(['Revenue', 'Expenses', 'Assets', 'Liabilities', 'Equity', 'System Controls']);
$("table.report").DataTable({
paging: false,
dom: "t",
order: [
[2, 'enum'],
[1, 'asc'],
],
rowGroup: {
dataSrc: [2, 1],
emptyDataGroup: null
},
columnDefs: [
{
type: "enum",
targets: [2]
},
{
targets: [1,2], visible: false
},
],
});
This discussion has been closed.
Answers
Apologies, I am getting the error it seems without rowgroup. So this gives the same error -
Not sure why you are getting the error "A" is not a function. But you do have a couple issues.
First is this:
According to the
order
docs you can supplyasc
ordesc
for the order:Instead of using
enum
you need to either useasc
ordesc
.Second Datatables automatic type detection will determine if one or more columns will determine if the column matches the
enum
array. If all the values in the column are found in the array then it will automatically type it asenum
. If not it will type it appropriately as described in thecolumns.type
docs. Likely you will need to removetype: "enum",
to allow auto detection to work. If you assing it the column might not be assigned to theenum
type and be sorted using a different type.See this example of using
enum
on the Office column. See theorder option
. Try uncommenting thetype: 'enum'
to see that the ordering doesn't work as expected.http://live.datatables.net/sosolaco/1/edit
If all this doesn't help then please provide a link to your page or a test case replicating the issue so we can help debug:
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Thanks for the feedback. I've solved the problem now -
I didn't realise it was clever enough to work all this out.