Propper filtering of the fields with html tags

Propper filtering of the fields with html tags

dhamma.giftdhamma.gift Posts: 4Questions: 0Answers: 0

Hi everyone
Please help me with the following problem:
Here is the link to the table on the screenshot

Link to test case:
https://find.dhamma.gift/result/baahiy_suttanta_pali_7-62.html

Bāhiyasutta - if you type it into search without htmltags the entry doesn't appear in results
If with
Bāhiya</b>sutta - it appear in results

Description of problem:
On this screenshot you can see that filtering works with htmltags

But i need to get the same result without html tags.
May be there is some option to ignore htmltags in search, or how to fix this problem.

Replies

  • kthorngrenkthorngren Posts: 17,724Questions: 25Answers: 4,204

    See if this strip html search plugin works for you.

    Kevin

  • dhamma.giftdhamma.gift Posts: 4Questions: 0Answers: 0
    edited November 2022

    Hello @kthorngren and thank you for the reply

    Sorry if it's a silly question. I'm not a developer and everytime when it's a js question I start panicking .

    I've tried to add this plug-in on this table to the html head and body
    https://find.dhamma.gift/result/baahiya_suttanta_pali_3-38.html

    Head part

    <script type="text/javascript" src="/assets/js/strip-html.js"></script>
    

    Body part

        <script type='text/javascript'>
    $(document).ready(function (){
    
         var table = $('#pali').DataTable({
           'autoWidth': true,
           'stateSave': true,
            'paging'  : true,
          'responsive': true,
          'columnDefs': [
                    { type: 'natural', targets: '_all' },
                    { type: "html", target: 0 }
                        ]               
        });
          
          
        // Handle click on "Expand All" button
        $('#btn-show-all-children').on('click', function(){
            // Expand row details
            table.rows(':not(.parent)').nodes().to$().find('td:first-child').trigger('click');
        });
        // Handle click on "Collapse All" button
        $('#btn-hide-all-children').on('click', function(){
            // Collapse row details
            table.rows('.parent').nodes().to$().find('td:first-child').trigger('click');
        });
    });
      </script>
    

    Here is the table with code above. But the problem remains. May be I'm just using its wrong?
    https://find.dhamma.gift/result/baahiya_suttanta_pali_3-38.html

  • kthorngrenkthorngren Posts: 17,724Questions: 25Answers: 4,204

    You applied the strip html plugin to only column 0:

          'columnDefs': [
                    { type: 'natural', targets: '_all' },
                    { type: "html", target: 0 }
                        ]               
    

    Looks like you have the natural plugin for sorting numbers with letters. You probably need to change the columnDefs.targets that you apply these plugins to. Maybe something like this:

          'columnDefs': [
                    { type: 'natural', targets: 0 },
                    { type: "html", target: [1,2] }
                        ]               
    

    Kevin

  • dhamma.giftdhamma.gift Posts: 4Questions: 0Answers: 0

    Thank you so much @kthorngren
    It works. In combination with natural sorting it looks like this

    'columnDefs': [
                    { type: "html", target: [1,2] },
                    { type: 'natural', targets: 0 }
                        ]
    
Sign In or Register to comment.