Perform regex search on data with hyperlinks

Perform regex search on data with hyperlinks

pradeepzpradeepz Posts: 4Questions: 2Answers: 1

Hello,

Firstly, I must thank you for giving us an awesome plugin to manage html tables.

My actual question is:
I have column(0) full of hyperlinks.
I want to run a customized search with the same search box that comes from the plugin.

.withOption('initComplete', function(){
    var typingTimer;                //timer identifier
    var doneTypingInterval = 2000;  //time in ms, 2 second
    var $input = $('#empSearch').children().find('input');

    //on keyup, start the countdown
    $input.on('keyup', function () {
        clearTimeout(typingTimer);
        typingTimer = setTimeout(doneTyping, doneTypingInterval);
    });

    //on keydown, clear the countdown 
    $input.on('keydown', function () {
        clearTimeout(typingTimer);
    });

    function doneTyping(){
        var val = $input.val();
        if (val.length == 6)
        {
            var table = $('.example1').DataTable();
            $http({
                url: 'headcount/getProjectsEmployeeWorkedOn',
                method: 'post',
                data: {month:month, year:year, empNo:val}
            }).success(function(response){
                if (response.data && !response.error)
                {
                    var projects = response.data;
                    var projectsArray = Object.keys(projects).map(function(k) { return projects[k] });
                    projects = '('+projectsArray.toString().split(',').join('\\b(?![-_])|')+'\\b(?![-_]))';
                    table.column(0).data().search(projects,true,false,true).draw();
                    console.log(projects);
                }
            });
        }
    }
})

In the above regex I need to add a space in the negative lookahead.
But if I do that it eliminates all the entries because they are with anchor tags.
Is there a way to string tags from table.column(0).data() before I go for .search() ?

I do not want to change the source code or create a custom filter.

Regards,
Chaitanya.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,309Questions: 26Answers: 4,947
    Answer ✓

    I'm not sure what your regex string looks like nor what your hyperlinks look like but you may be able to use columns.render to render the filter type to something you can search on.

    Kevin

  • pradeepzpradeepz Posts: 4Questions: 2Answers: 1

    Thanks Kevin, will try that.

This discussion has been closed.