Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81688

Server-side grouping possible with fnDrawCallback?

$
0
0
I'm trying to group the values in the first column of server-side (json) created table and it appears the fnDrawCallback fuction actually does work since I get no errors and the first column is hidden, but where the groupname should "undefined" is stated.

screenshot that should clear things up: http://s16.postimage.org/o5ig167yt/grouping.png

here's me debugger link http://debug.datatables.net/unuwiy

and my js:


$(document).ready( function() {
			  var oTable = $('#example').dataTable( {
				"sAjaxSource": "json_gespeeldekaartings.php",
				"aoColumns": [
				  { "mData": "kaarting" },
				  { "mData": "speler" },
				  { "mData": "punten" }
					],
				"sAjaxDataProp": "",
				"aaSorting": [],
				
				"fnDrawCallback": function ( oSettings ) {
					if ( oSettings.aiDisplay.length == 0 )
					{
						return;
					}
					  
					var nTrs = $('#example tbody tr');
					var iColspan = nTrs[0].getElementsByTagName('td').length;
					var sLastGroup = "";
					for ( var i=0 ; i<nTrs.length ; i++ )
					{
						var iDisplayIndex = oSettings._iDisplayStart + i;
						var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[0];
						if ( sGroup != sLastGroup )
						{
							var nGroup = document.createElement( 'tr' );
							var nCell = document.createElement( 'td' );
							nCell.colSpan = iColspan;
							nCell.className = "group";
							nCell.innerHTML = sGroup;
							nGroup.appendChild( nCell );
							nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
							sLastGroup = sGroup;
						}
					}
				},
				"aoColumnDefs": [
					{ "bVisible": false, "aTargets": [ 0 ] }
				],
				
				"sDom": 'lfr<"giveHeight"t>ip'
					
				} );
			} );



Thanks for the help!

Viewing all articles
Browse latest Browse all 81688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>