Disable Smart Filter and Enable Regex Filtering

Disable Smart Filter and Enable Regex Filtering

damaya1982damaya1982 Posts: 12Questions: 0Answers: 0
edited August 2013 in DataTables 1.9
Is there any way to make the search box in the header only do regex filtering? The example for regex filtering does not show how to do this. Basically, just make the search box that is already there globally filter on regex rather than smart for any search term that is entered.

Replies

  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Sure - use the oSearch options on initialisation: http://datatables.net/ref#oSearch

    Allan
  • damaya1982damaya1982 Posts: 12Questions: 0Answers: 0
    That's not doing anything for me. I am trying to filter a single column that can contain many different values, but I am looking for two in particular. I am doing "complete|abort" and I am getting nothing. Obviously, that is without the quotes.

    The different ways I have done it are:

    [code]
    "oSearch": {"sSearch": "a", "bRegex":true, "bSmart": false},
    "oSearch": {"bRegex":true, "bSmart": false},
    "oSearch": {"bRegex":true},
    [/code]


    [code]
    var table = $('#unit-view-table');
    table.dataTable({
    "oSearch": {"bSmart": false},
    "sScrollY": "500px",
    "sScrollX": "100%",
    //"sScrollXInner": "150%",
    //"sScrollYInner": "150%",
    "bScrollCollapse": true,
    "bStateSave": true,
    "bSortClasses": false,
    "bDeferRender": true,
    "oColVis": {
    //"buttonText": "Show / Hide columns",
    "bRestore": true,
    //"aiExclude": [ 18, 19 ]
    // "sAlign": "left"
    },
    "iDisplayLength": 500,
    "bPaginate": false,
    "aLengthMenu": [[-1, 25, 50, 100], ["All", 25, 50, 100]],
    "bProcessing": true,
    //"bServerSide": true,
    "sAjaxSource": "/cgi-bin/v_server.pl?action=output_json",
    'aoColumns': [
    /* 0 Host */
    {
    "mData": "host",
    "bVisible": false,
    "sDefaultContent": " "
    },
    /* 1 Location */
    {
    "mData": "loc_ser",
    "sDefaultContent": " "
    },
    /* 2 Outcome */
    {

    "mData": "outcome",
    "sDefaultContent": " "
    },
    /* 3 msg */
    {
    "mData": "notes",
    "bSortable": false,
    "sDefaultContent": " "
    },
    /* 4 Run Time */
    {
    "mData": "run_time",
    "bVisible": false,
    "sDefaultContent": " "
    },
    /* 5 Work Order */
    {
    "mData": "workorder",
    "bVisible": false,
    "sDefaultContent": " "
    },
    /* 6 Actions */
    {
    "mData": "menu",
    "bSortable": false,
    "sDefaultContent": " "
    },
    /* 7 Proceed */
    {
    "mData": "button",
    "bSortable": false,
    "sDefaultContent": " "
    }
    ],
    'sPaginationType': 'full_numbers',
    "sDom": 'RC<"clear"><"dataTables_header"lfr>t<"dataTables_footer"ip>',

    'fnInitComplete': function( oSettings )
    {
    // Style length select
    table.closest('.dataTables_wrapper').find('.dataTables_length select').addClass('select blue-gradient glossy').styleSelect();
    tableStyled = true;
    }
    }).fnSetFilteringDelay();
    [/code]
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    I've just put together: http://live.datatables.net/ucilib/edit#javascript,html .

    If you type `Webkit|Presto` into the filter it does the expected OR.

    Try disabling the filtering delay plug-in. I think that when fnFilter is called it is reseting the defaults in the instance to its own defaults (which is crap thing to do...).

    Allan
This discussion has been closed.