delete/hide row from datatable

delete/hide row from datatable

josephejosephe Posts: 11Questions: 0Answers: 0
edited September 2011 in General
could somebody advice me how to delete or hide entire row which has some atribute please?
I think this is the way but dont know how to adjust it for this purpose :

"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
if ( aData[8] == "Active" )
{
$('td:eq(7)', nRow).html( 'Active' );
}
return nRow;
},

Replies

  • josephejosephe Posts: 11Questions: 0Answers: 0
    I think one way to remove row is by this way referencing by id of row :
    $('#myTableRow').remove();
    but how to force datatables to ajax serverprocessing to put some field value into id of row?
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    by default (when using server processing) DataTables will use the value of column 0 as the id for the row.

    if you want to override this, you should look into the object version of aaData, and use DT_RowID. http://www.datatables.net/usage/server-side
  • josephejosephe Posts: 11Questions: 0Answers: 0
    thanks for reply fbas
    I use default server processing and in result there is no id for row :



    5
    bla bla bla
    xxx
    2009-09-01 10:00:00
    2010-09-01 10:00:00
    zzz
    bbb
    aaa
    Stopped


    2
    ble ble ble
    yyyy
    2011-08-01 15:00:00
    2011-09-30 15:15:00
    ..... etc

    is it any sample available to see how to create on server side object version of aaData?
  • josephejosephe Posts: 11Questions: 0Answers: 0
    in meantime I found in forum your explanation ( http://www.datatables.net/forums/discussion/6070/how-input-value-id-in-after-receive-data-from-serverside/p1 ) how to create object version and it works just change this part of code :
    [code]
    $row->DT_RowId = $aRow[ $aColumns[8] ];
    [/code]

    ...in onload function of datatables I got this :
    [code]
    "fnRowCallback": function( nRow, aData, iDisplayIndex ) {

    if ( aData[8] == "Active" )
    {
    $('#Active').remove();
    //$('td:eq(7)', nRow).html( 'Active' );
    }
    return nRow;
    },
    [/code]
    ...even if my data has some row with row id = Active this row is not removed :(
  • josephejosephe Posts: 11Questions: 0Answers: 0
    could somebody advice me please how to aply filter to datatables onload data ...similar like it is here http://datatables.net/examples/api/multi_filter.html but not on even keyup in input but on upload of data filtered by predefined value of exact column....
  • josephejosephe Posts: 11Questions: 0Answers: 0
    I got it...
    I just filter aData for each table separately by

    [code]
    oTable1.fnFilter( 'filtered_text1', 8 );
    oTable2.fnFilter( 'filtered_text2', 8 );
    ...
    [/code]
This discussion has been closed.