oSettings.oApi._fnGetTrNodes(oSettings) old function migrate
oSettings.oApi._fnGetTrNodes(oSettings) old function migrate

In https://datatables.net/forums/discussion/20989, allan says _fnGetTrNodes
was removed in DataTables 1.10. New dom sorting examples can be found at https://datatables.net/examples/plug-ins/dom_sort.html.
However, some plugins using this api are so old that the author no longer mantained. https://github.com/djwoodward/jquery-datatables-row-grouping/blob/master/media/js/jquery.dataTables.rowGrouping.js is an example.
rowGrouping.js uses this api in https://github.com/djwoodward/jquery-datatables-row-grouping/blob/master/media/js/jquery.dataTables.rowGrouping.js#L646:
/* Create an array with the values of all the input boxes in a column */
oTable.fnSettings().aoColumns[properties.iGroupingOrderByColumnIndex].sSortDataType = "rg-letter";
$.fn.dataTableExt.afnSortData['rg-letter'] = function (oSettings, iColumn) {
var aData = [];
$('td:eq(' + iColumn + ')', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
aData.push(_fnGetGroupByLetter(this.innerHTML));
});
return aData;
}
I find an old dom sorting example in https://datatables.net/beta/1.7/examples/plug-ins/dom_sort.html.
/* Create an array with the values of all the input boxes in a column */
$.fn.dataTableExt.afnSortData['dom-text'] = function ( oSettings, iColumn )
{
var aData = [];
$( 'td:eq('+iColumn+') input', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
aData.push( this.value );
} );
return aData;
}
The comment line leads me to find the same example in new dom sorting example:
/* Create an array with the values of all the input boxes in a column */
$.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
{
return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
return $('input', td).val();
} );
}
I edit the precious code to
/* Create an array with the values of all the input boxes in a column */
oTable.fnSettings().aoColumns[properties.iGroupingOrderByColumnIndex].sSortDataType = "rg-letter";
$.fn.dataTable.ext.order['rg-letter'] = function ( settings, col )
{
return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
return $('input', td).val();
} );
}
But on $.fn.dataTable.ext.order['rg-letter']
it says
Uncaught TypeError: Cannot set property 'rg-letter' of undefined
I guess it is the following two lines doesn't match:
oTable.fnSettings().aoColumns[properties.iGroupingOrderByColumnIndex].sSortDataType = "rg-letter";
$.fn.dataTable.ext.order['rg-letter']
Does anyone how to fix it? Thanks in advance.
This question has an accepted answers - jump to answer
Answers
What are you trying to do?
Are you looking for a row grouping solution? If so Datatables has a RowGroup Extension.
Kevin
Agreed - rather than trying to workaround the changes in unsupported software, it would probably be better to just use RowGroup (assuming it does what you need).
Allan