troubleshooting Question

Grouped DataTables: Can I dynamically pass in the number of columns?

Avatar of Crystal Rouse
Crystal RouseFlag for United States of America asked on
1 Comment1 Solution109 ViewsLast Modified:
I use DataTables all through our site and really look the grouped tables.  Is there a way to dynamically pass in the number of columns?  I have several instances used that all I do is change the number of columns.  It would be nice to be able to use it globally.

            "aaSorting": [],
            "pageLength": 1000,
            "columnDefs": [
                { "visible": false, "targets": 1 }
            "drawCallback": function (settings) {
                var api = this.api();
                var rows = api.rows({ page: 'current' }).nodes();
                var last = null;
                api.column(1, { page: 'current' }).data().each(function (group, i) {
                    if (last !== group) {
                            '<tr class="group"><td colspan="5">' + group + '</td></tr>'
                        last = group;
Dustin Saunders
Co-Founder and Chief Architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2016

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros