ServerSide & MultyFiltering

ServerSide & MultyFiltering

MaximusFTMaximusFT Posts: 4Questions: 0Answers: 0
edited August 2011 in General
Ну во первых - есть ли тут русскоговорящие?
А во вторых - может кто подскажет как при использовании СерверСайда в строке поиска можно было вводить слова через пробел и он продолжал искать, так же как на клиентской стороне.
И еще вопрос как к Сервер сайду - Individual column filtering (using "input" elements)?

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    edited August 2011
    http://translate.google.com/ is my friend

    1) BREAKING UP SEARCH TERMS BY SPACE
    basically you can recode a little on the server side to have it break up words by white space.

    I did something like this, and added a checkbox to allow users to choose a literal search of the filter box OR a "keyword search" in which I break up the words by space. The checkbox is named "kw", and I place it next to the Filter textbox using fnInitComplete:

    see: http://i.imgur.com/cgbUX.jpg

    [code]
    oTable = $('#results_table').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "bUseRendered": false,
    "sAjaxSource": "qafiles_json.php",
    "fnServerData": function ( sSource, aoData, fnCallback ) {
    /* allow users to break oSearch into separate keywords */
    aoData.push( { "name": "kw", "value": $('#kw').is(":checked") } );

    $.ajax( {
    "dataType": 'json',
    "url": sSource,
    "data": aoData,
    "success": fnCallback
    } );
    },
    "fnInitComplete": function() {
    // add a checkbox for keyword search next to the filter
    $('#results_table_filter').append(' Keyword Search');
    $('#results_table_filter').change(oTable.fnStandingRedraw);
    }
    // etc.
    [/code]


    on the server side, detect the "kw" parameter
    [code]
    if ( isset($_GET['sSearch']) && $_GET['sSearch'] != "" )
    {
    $sSearch = mysql_real_escape_string( $_GET['sSearch'] );
    $aSearch = array();

    if (isset($_GET['kw']) && $_GET['kw'] == "true") {
    $aSearch = explode(' ', $sSearch);
    // remove empty items from search
    $aSearch = array_filter($aSearch);
    }

    // add unbroken $sSearch to array terms if it's not there
    if (!in_array($sSearch, $aSearch)) array_unshift($aSearch ,$sSearch);
    $sWhere = "WHERE (";

    foreach ($aSearch as $term) {
    for ( $i=0 ; $i
This discussion has been closed.