Break on column, need custom sort or fnDrawCallback?
Break on column, need custom sort or fnDrawCallback?
abbottmw
Posts: 29Questions: 0Answers: 0
I am outputting my table with the first column only showing the data the first time unless it is different... it is the same as using BREAK ON in Oracle..
Here is the DataTables live preview..
http://live.datatables.net/amabuw/2
As you can see the first column is like
IE
...
...
...
Trident
...
...
Gecko
What I would like to do is treat the empty column as the previous cell that had a value to it so..
IE
...
...
...
the empty columns in this case would be seen as IE until it changed to Trident or something else.
Would I have to do this using a custom sorter or using the fnDrawCallback?
If it is a custom sorter, I am not sure how to go about creating it. I know I need to hold onto the non empty value and when it changes update it, otherwise use that as the sorting text. Just cant seem to wrap my head around the logic, so I need some help.
If it is a fnDrawCallback() is there a way to set the value Datatables is looking at for that cell without setting the value of that cell?
Any assistance is greatly appreciated!!
Here is the DataTables live preview..
http://live.datatables.net/amabuw/2
As you can see the first column is like
IE
...
...
...
Trident
...
...
Gecko
What I would like to do is treat the empty column as the previous cell that had a value to it so..
IE
...
...
...
the empty columns in this case would be seen as IE until it changed to Trident or something else.
Would I have to do this using a custom sorter or using the fnDrawCallback?
If it is a custom sorter, I am not sure how to go about creating it. I know I need to hold onto the non empty value and when it changes update it, otherwise use that as the sorting text. Just cant seem to wrap my head around the logic, so I need some help.
If it is a fnDrawCallback() is there a way to set the value Datatables is looking at for that cell without setting the value of that cell?
Any assistance is greatly appreciated!!
This discussion has been closed.
Replies
Here is what i was playing with..
[code]
function breakOn(sort_name){
var base = "";
$.fn.dataTableExt.afnSortData[sort_name] = function ( oSettings, iColumn )
{
var aData = [];
$( 'td:eq('+(iColumn)+')', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
if(base != $.trim($(this).text()) && $.trim($(this).text()) != "" ){
base = $.trim($(this).text());
}
aData.push( base );
} );
return aData;
}
}
//i may have multiple columns that was like this so I made it into a function
//I then added a sSortDataType :'break-on' in the DT setup call.
breakOn('break-on');
[/code]
Just wanted to post what i was working with just in case it would help someone in the future.