Server-Side Filtering Problem
Server-Side Filtering Problem
UnkleFrank
Posts: 5Questions: 0Answers: 0
Hi all
New to DataTables and really struggling with this one. I'd like to be able to add filtering to a few/all columns but after a couple of days of attempts, I still have no success. I'm including my HTML and the header of the ajax/PHP file as reference. Maybe someone can see a simple solution...?
Thanks in advance to all.
Frank
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
'bServerSide':true,
"sAjaxSource": "conn3.php",
"aLengthMenu": [10, 25, 50, 100],
/* "aaSorting": [[ 3, "asc" ]],
*/ "sPaginationType": "full_numbers",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "state": "text", "value": $('#state_filter').val() } );
$.getJSON( sSource, aoData, function (json) {
fnCallback(json)
} );
}
}
).columnFilter({
aoColumns: [ { sSelector: "#bus_name" },
{ sSelector: "#street" },
{ sSelector: "#city" },
{ sSelector: "#state" },
{ sSelector: "#zip" },
{ sSelector: "#tele" }
]
} );
$('#state_filter').keyup( function () {
oTable.fnDraw();
} );
} );
Column
Filter
Name
Street
City(s)
State
Zip
Tele
Restaurant Name
Street Address
City
State
Zip Code
Telephone
bus_name
street
city
state
zip
tele
[/code]
PHP File
[code]
<?php
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2010 - Allan Jardine, 2012 - Chris Wright
* License: GPL v2 or BSD (3-point)
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array( 'bus_name', 'street', 'city', 'state', 'zip', 'tele' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "bus_id";
/* DB table to use */
$sTable = "business";
[/code]
New to DataTables and really struggling with this one. I'd like to be able to add filtering to a few/all columns but after a couple of days of attempts, I still have no success. I'm including my HTML and the header of the ajax/PHP file as reference. Maybe someone can see a simple solution...?
Thanks in advance to all.
Frank
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
'bServerSide':true,
"sAjaxSource": "conn3.php",
"aLengthMenu": [10, 25, 50, 100],
/* "aaSorting": [[ 3, "asc" ]],
*/ "sPaginationType": "full_numbers",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "state": "text", "value": $('#state_filter').val() } );
$.getJSON( sSource, aoData, function (json) {
fnCallback(json)
} );
}
}
).columnFilter({
aoColumns: [ { sSelector: "#bus_name" },
{ sSelector: "#street" },
{ sSelector: "#city" },
{ sSelector: "#state" },
{ sSelector: "#zip" },
{ sSelector: "#tele" }
]
} );
$('#state_filter').keyup( function () {
oTable.fnDraw();
} );
} );
Column
Filter
Name
Street
City(s)
State
Zip
Tele
Restaurant Name
Street Address
City
State
Zip Code
Telephone
bus_name
street
city
state
zip
tele
[/code]
PHP File
[code]
<?php
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2010 - Allan Jardine, 2012 - Chris Wright
* License: GPL v2 or BSD (3-point)
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array( 'bus_name', 'street', 'city', 'state', 'zip', 'tele' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "bus_id";
/* DB table to use */
$sTable = "business";
[/code]
This discussion has been closed.
Replies
I don't see your sDom specified, hence no columnfilterwidgets.