Plugin searchHighlight

Plugin searchHighlight

ArmandArthurArmandArthur Posts: 10Questions: 2Answers: 0

Hello,

The plugin match all columns, but sometimes i have HTML element in my Datatable and would like not use the hightligh search on the columns which contains the element html.

It's possible to have the searchHiglight on a specific columns?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586
    Answer ✓

    Hi @ArmandArthur ,

    I think you should be able to change the code to do that. If you change line 46 to be

    table.columns([x,y,x]).every( function () {
    

    where [x,y,z] are the columns you want applied, it may do the trick :)

    Cheers,

    Colin

  • ArmandArthurArmandArthur Posts: 10Questions: 2Answers: 0

    I think you are right, thx

  • ArmandArthurArmandArthur Posts: 10Questions: 2Answers: 0

    It's possible to modify the search global on specific columns?

  • ArmandArthurArmandArthur Posts: 10Questions: 2Answers: 0

    I modified this line :smile:

    body.highlight( $.trim( table.search() ).split(/\s+/) );

    by
    var columns = [0,1,2,3,4,5];
    table.columns(columns).every( function () {
    var column = this;
    column.nodes().flatten().to$().unhighlight({ className: 'highlight' });
    column.nodes().flatten().to$().highlight( $.trim( table.search() ).split(/\s+/), { className: 'highlight' } );
    } );

    and it works

This discussion has been closed.