search on special characters

search on special characters

rohit99rohit99 Posts: 22Questions: 9Answers: 0
edited December 2017 in Free community support

we need to search on special characters with rang filter.
like: salary type columns "$ 150,000"

Answers

  • allanallan Posts: 63,460Questions: 1Answers: 10,466 Site admin

    If you want to use a range filter, you need to implement a custom search plug-in. If you do that, you could just strip out non-numeric characters.

    Allan

  • rohit99rohit99 Posts: 22Questions: 9Answers: 0
    edited December 2017

    Thanks for help.

    But we have some trouble in

    $.fn.dataTable.ext.search.push

    If we use multiple table on one page. This method performed on both tables, but we need only one table.

  • rohit99rohit99 Posts: 22Questions: 9Answers: 0

    We use this, but not working
    $.fn.dataTable.ext.search.push(
    function (settings, data, dataIndex) {
    if (settings.nTable == document.getElementById('tblFlowdown')) {

  • allanallan Posts: 63,460Questions: 1Answers: 10,466 Site admin
    edited December 2017

    That should be how to do it. If it isn't working for you, please link to a test case showing the issue.

    Allan

  • rohit99rohit99 Posts: 22Questions: 9Answers: 0
    edited December 2017

    This is worked, if we use multiple table on one page.
    This method performed on both tables, but we need only one table.
    We can change $.fn.dataTable.ext.search.push to any other method ?

    $.fn.dataTable.ext.search.push(
    function (settings, data, dataIndex) {
    if (settings.nTable == document.getElementById('tblFlowdown')) {
    var _salary = data[8];

                        var _val = $('#filterByValue-FlowDown').val();
                        if (_val == "") {
                            _val = _salary;
                        }
                        _val = _val.replace(/,/g, "").trim();
                        _val = _val.replace("$", "").trim();
                        var searchVal = parseFloat(_val) || 0;
    
                        _salary = _salary.replace(/,/g, "").trim();
                        _salary = _salary.replace("$", "").trim();
                        var salary = parseFloat(_salary) || 0;
    
    
                        if (searchVal >= salary) {
                            return true;
                        }
                        return false;
                    }
                });
    
  • rohit99rohit99 Posts: 22Questions: 9Answers: 0

    We can change $.fn.dataTable.ext.search.push to any other method. Just like ('#tblFlowdown').DataTable().column(col).

  • allanallan Posts: 63,460Questions: 1Answers: 10,466 Site admin

    No not yet. That is something that will be added in a future version of DataTables.

    At the moment you need to do an id check inside your custom filtering function, just like you have done.

    Allan

This discussion has been closed.