Break on column, need custom sort or fnDrawCallback?

Break on column, need custom sort or fnDrawCallback?

abbottmwabbottmw Posts: 29Questions: 0Answers: 0
edited March 2013 in DataTables 1.9
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!!

Replies

  • abbottmwabbottmw Posts: 29Questions: 0Answers: 0
    I ended up writing a plugin to do this but then decided it wouldn't be that beneficial since the way the table i'm using this for would make it where you don't know which group the record is for. It would be better to use column grouping in this case, but for my requirement, I cannot do this so I am leaving it as is..

    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.
This discussion has been closed.