Column filter on server side

Column filter on server side

plastelinkoplastelinko Posts: 5Questions: 2Answers: 0
edited January 2015 in Free community support

When I want to implement option columnFilter on Server side, I don't receive response, only show "Processing..."
Help? where is error? or how to call datatable to show results picked from query in db.php file?

processing" : true,
                    "serverSide" : true,
                    "sAjaxSource": "db.php",
                    "sPaginationType" : "full_numbers",                 
                    "fnServerData" : function(sUrl, aoData, fnCallback) {
                        aoData.push({"name":"id","value":""});
                        $.ajax({
                            "contentType": "application/json; charset=utf-8",
                            "url" : sUrl,
                            "data" : aoData,
                            "type":"GET",
                            "success" : function(response){
                                t.fnReloadAjax();
                            },
                            "dataType" : "json"                         
                        });
                    }               
            }).columnFilter({
                    aoColumns : [null,{ type:"text"},{ type:"text"},{
                        type : "select",
                        values : ['tip1', tip2', 'tip3', 'tip4']
                    }, {
                        type : "text"
                    }, {
                        type : "text"
                    }, {
                        type : "text"
                    },
                    null]
                });

Thank you!

```php
<?php

include("dbconfig.php");
$table = $db_table;
$primaryKey = 'id';
$myJoin = " INNER JOIN table2 ON table1.idExternal = table2.id ";

$columns = array(
array(
'db' => 'id',
'dt' => 'DT_RowId',
'formatter' => function( $d, $row ) {
return $d;
}
),
array( 'db' => 'column0', 'dt' => 0 ),
array( 'db' => 'column1', 'dt' => 1 ),
array( 'db' => 'column2', 'dt' => 2 ),
array( 'db' => 'column3', 'dt' => 3 ),
array( 'db' => 'column4', 'dt' => 4 ),
array( 'db' => 'column5', 'dt' => 5,'formatter' => function( $d, $row ) {
return date( 'jS M y', strtotime($d));
}),
array( 'db' => 'column6', 'dt' => 6 ),
array( 'db' => 'column7', 'dt' => 7 )
);

// SQL server connection information

$sql_details = array(
'user' => $db_user,
'pass' => $db_pass,
'db' => $db_db,
'host' => $db_server
);
require( 'DataTables-1.10.4/examples/server_side/scripts/ssp.class.php' );
echo json_encode(SSP::simple( $_GET, $sql_details, $table,$myJoin, $primaryKey, $columns ));

<?php > ``` ?>

Answers

  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin

    only show "Processing..."

    There is an error in the server-side script in that case. Look at the Ajax return in your browser's developer tools to find out what the error is.

    Allan

  • plastelinkoplastelinko Posts: 5Questions: 2Answers: 0
    edited January 2015

    db.php file, that return ajax data, show error:

    Undefined index: draw in C:\wamp\www\project\DataTables-1.10.4\examples\server_side\scripts\ssp.class.php on line 247

    Notice: Undefined index: draw in C:\wamp\www\project\DataTables-1.10.4\examples\server_side\scripts\ssp.class.php on line 247
    {"draw":0,"recordsTotal":33,"recordsFiltered":17,"data":[{"DT_RowId":"4","0":"4","1":"John","2":"Johans","3":"SQL","4":"MSS IT","5":"5th Mar 15","6":"110000000","7":"299856177"},{"DT_RowId":"7","0":"7","1":"Ann","2":"Lucac","3":"PHP developer","4":"MM Group","5":"5th Mar 15","6":"110000000","7":"299856177"};
    

    In debug information i have this:

    Request URL:http://localhost/jqGrid_Alen%20-%20kopija/db.php?sEcho=1&iColumns=8&sColumns=%2C%2C%2C%2C%2C%2C%2C&iDisplayStart=0&iDisplayLength=10&mDataProp_0=0&sSearch_0=&bRegex_0=false&bSearchable_0=true&bSortable_0=true&mDataProp_1=1&sSearch_1=&bRegex_1=false&bSearchable_1=true&bSortable_1=true&mDataProp_2=2&sSearch_2=&bRegex_2=false&bSearchable_2=true&bSortable_2=true&mDataProp_3=3&sSearch_3=&bRegex_3=false&bSearchable_3=true&bSortable_3=true&mDataProp_4=4&sSearch_4=&bRegex_4=false&bSearchable_4=true&bSortable_4=true&mDataProp_5=5&sSearch_5=&bRegex_5=false&bSearchable_5=true&bSortable_5=true&mDataProp_6=6&sSearch_6=&bRegex_6=false&bSearchable_6=true&bSortable_6=true&mDataProp_7=7&sSearch_7=&bRegex_7=false&bSearchable_7=true&bSortable_7=true&sSearch=&bRegex=false&iSortCol_0=4&sSortDir_0=asc&iSortingCols=1&sRangeSeparator=~
    Request Method:GET
    ...
    ...
    Query String Parameters
    sEcho:1
    iColumns:8
    sColumns:,,,,,,,
    iDisplayStart:0
    iDisplayLength:10
    mDataProp_0:0
    sSearch_0:
    bRegex_0:false
    bSearchable_0:true
    bSortable_0:true
    mDataProp_1:1
    sSearch_1:
    bRegex_1:false
    bSearchable_1:true
    bSortable_1:true
    mDataProp_2:2
    sSearch_2:
    bRegex_2:false
    bSearchable_2:true
    bSortable_2:true
    mDataProp_3:3
    sSearch_3:
    bRegex_3:false
    bSearchable_3:true
    bSortable_3:true
    mDataProp_4:4
    sSearch_4:
    bRegex_4:false
    bSearchable_4:true
    bSortable_4:true
    mDataProp_5:5
    sSearch_5:
    bRegex_5:false
    bSearchable_5:true
    bSortable_5:true
    mDataProp_6:6
    sSearch_6:
    bRegex_6:false
    bSearchable_6:true
    bSortable_6:true
    mDataProp_7:7
    sSearch_7:
    bRegex_7:false
    bSearchable_7:true
    bSortable_7:true
    sSearch:
    bRegex:false
    iSortCol_0:4
    sSortDir_0:asc
    iSortingCols:1
    sRangeSeparator:~
    
    
  • plastelinkoplastelinko Posts: 5Questions: 2Answers: 0

    When I remove "sAjaxSource": "db.php" and columnFilter({...}) from jQuery code, data are shown, but don't have column filter on server side what I need...

  • umair_malikumair_malik Posts: 7Questions: 3Answers: 0

    please answer this question too about datatable server side filtering. thanks

    http://datatables.net/forums/discussion/comment/71584#Comment_71584

  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin

    @umair_malik - Please follow the forum rules and don't post duplicates. You are less likely to get a reply if you break the rules.

    Allan

This discussion has been closed.