How to filter by content in a column ignoring part of the content

How to filter by content in a column ignoring part of the content

nickog3dnickog3d Posts: 4Questions: 0Answers: 0
edited June 2012 in DataTables 1.9
Is there a way to mark part of cells' content as not searchable? I am successfuly using the bSearchable feature but I need to display more info in same cell.

Something like:
[code]John Doe General Manager[/code]

I am thinking of appending content from other cell into this one( "Position" in same cell with "Name"). But I fear that when searching for part of a name, users may find results related to the position instead.

Any ideas how I can achieve this? I've been looking around but could not find anything similar.

Replies

  • nickog3dnickog3d Posts: 4Questions: 0Answers: 0
    edited June 2012
    I wrote this code and it works, searches are made only on the initial content. But is it a good practice?

    [code]
    //copy position into name cell
    $('#DataTables_Table_0').find('tr').each(function(e){
    if(e!=0){
    var h = $(this).find('.views-field-title');
    var t = h.html();
    h.html(t + "
    " + $(this).find('.views-field-field-job-title').html() + "");
    }
    });
    [/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    A type based custom filter is the built in way to DataTables to do this: http://datatables.net/development/filtering#type_based .

    The other option is to use mDataProp (and soon mRender - post on that coming up) to give data back specifically for the filter - see: http://datatables.net/blog/Orthogonal_data

    Allan
This discussion has been closed.