i want fix one row as first row alway by filtering with one column value(admin)

i want fix one row as first row alway by filtering with one column value(admin)

saireddysaireddy Posts: 4Questions: 2Answers: 0

my code
var indexes = displayTable.rows().eq( 1).filter( function (rowIdx) {
return datatable.cell( rowIdx, 0 ).data().toLowercase() === 'Admin' ? true : false;
} );
var data = displayTable.row(indexes).data();
for (i = 0; i < data.length; i++) {
$('.second').find('th').eq(i).html( data[i] );
}
displayTable.row(indexes).remove().draw(false);

Answers

  • saireddysaireddy Posts: 4Questions: 2Answers: 0
    edited July 2017

    hello all , please help me on this

  • kthorngrenkthorngren Posts: 20,255Questions: 26Answers: 4,761

    return datatable.cell

    I think you want to change your return statement to this:

    return displayTable.cell

    Kevin

  • allanallan Posts: 61,627Questions: 1Answers: 10,090 Site admin

    I'm not actually sure what your question is. The filter() method has no effect on the data that is displayed in the table, as explained in its documentation.

    Do you want to keep one row at the top of the table, even if it doesn't match the filtering? If so, put that row into the thead.

    Allan

  • saireddysaireddy Posts: 4Questions: 2Answers: 0

    thanks allan and kevin for fast reply .
    i have suppose 4 rows of table data , in second column i want filter my data which is equal to admin then that row needs to be display as first row.

  • allanallan Posts: 61,627Questions: 1Answers: 10,090 Site admin
    displayTable.column( 1 ).search( 'admin' ).draw();
    

    Allan

This discussion has been closed.