Search column with hyperlink

Search column with hyperlink

n14463n14463 Posts: 4Questions: 2Answers: 0
edited April 2019 in Free community support

I didn't realize it will not be straight-forward. Can someone help me what do i need to do to search data in this hyperlink column? Please help

Below is my code

table = $('#tbl_samples_incomplete').DataTable({
            "dom": 'frtip',
            "responsive": true,
            "lengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]],
            "select": true,
            "paging": true,
            "searching": true,
            "filter": true,
            "orderMulti": false,            
            "columns":
                [
                    { data: "Id", title: "Identifier", orderDataType: "dom-text", type: 'string' }
                ],            
            'columnDefs': [                
                {            
                    "targets": [0],                    
                    "render": function (data, type, row, meta) {
                        
                        if (type === 'display') {
                            var link = window.applicationBaseUrl + 't/test?sId=' + row.sId;
                            data = '<a href="' + link + '">' + data + '</a>';

                            return data;
                        }
                    }

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @n14463 ,

    In the columns.render function, you're only returning data if the type is display. Have a return value for all other types, and if you want a search/filter type, have that too (type === 'filter').

    Cheers,

    Colin

  • n14463n14463 Posts: 4Questions: 2Answers: 0

    I see, let me try that

  • n14463n14463 Posts: 4Questions: 2Answers: 0

    Sweet, works fine. Thanks Colin!

This discussion has been closed.