My SOS call. Sorting and search not working...Please help

My SOS call. Sorting and search not working...Please help

zaibzaib Posts: 2Questions: 0Answers: 0
edited February 2011 in General
Hi Allan and Data table lovers

I am trying to put datatable in a project. The data table here can fetch the table from mysql but it is not sorting searching and "Processing..." status remains on the screen. Although it gets data from mysql. Please help me.


[code]





@import "media/css/demo_page.css";
@import "media/css/demo_table.css";



$(document).ready(function() {
$('#example').dataTable( {

//"sDom": '<"top"fl<"clear">>t<"bottom"ip<"clear">><"clear">',

"bProcessing": true,

"bServerSide": true,

"sPaginationType": "full_numbers",

"aoColumns": [
// 1 ID
{ "bSortable": false, "bSearchable": false },

// 2 Picture
{ "bSortable": false,"bSearchable": false },

// 3 Book Title
{ "sType": "html","sWidth": "200px"},

// 4 Author
{ "sType": "html"},

// 5 Publisher
{ "sType": "html","sWidth": "200px" },

// 6 Edition
{ "bSortable": false, "bSearchable": false },

// 7 Language
{ "sType": "html", "bSearchable": false },

// 8 Category
{ "bSearchable": false },

// 9 Price
{ "bSortable": false, "bSearchable": false },

// 10 Edit
{ "bSortable": false, "bSearchable": false },


// 11 Delete
{ "bSortable": false, "bSearchable": false }
],

// Sort first by town name, then by A.D., then by Geographic Area
"aaSorting": [[3, "asc"], [4, "asc"], [5, "asc"]],

// Edit messaging
"oLanguage": {
"sSearch": "SEARCH BY BOOK, AUTHOR OR PUBLISHER NAME:",
"sLengthMenu": 'Display '+
'10'+
'25'+
'50'+
//'100'+
//'All'+
' records at a time'
},

// Append Fond - Opys - Sprava - Part together into one column
/*
"aoColumnDefs": [
{
"fnRender": function ( oObj ) {
return oObj.aData[0] +' / '+ oObj.aData[1] +' / '+ oObj.aData[2] +' '+ oObj.aData[3];
},
"aTargets": [ 0 ]
},
{ "bVisible": false, "aTargets": [ 1,2,3 ] },
],
*/

// change color of text of certain rows
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
if ( aData[13] == "Acquired" )
{
$('td', nRow).addClass("acquired");
}
if ( aData[13] == "Rejected" )
{
$('td', nRow).addClass("rejected");
}
if ( aData[13] == "Examined" )
{
$('td', nRow).addClass("examined");
}
return nRow;
},

"sAjaxSource": "server_processing.php"
} );
} );



Royal Book Data



ID
Picture
Book Title
Author
Publisher
Edition
Language
Category
Price
Edit
Delete




Loading data from server




ID
Picture
Book Title
Author
Publisher
Edition
Lanaguage
Category
Price
Edit
Delete







[/code]

Replies

  • zaibzaib Posts: 2Questions: 0Answers: 0
    edited February 2011
    here is sever side code.

    [code]

    <?php
    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    * 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( 'id', 'thumb','title', 'author', 'publisher', 'edition', 'language', 'category', 'price');

    /* Indexed column (used for fast and accurate table cardinality) */
    $sIndexColumn = "id";

    /* DB table to use */
    $sTable = "books";

    /* Database connection information */
    $gaSql['user'] = "****";
    $gaSql['password'] = "";
    $gaSql['db'] = "****";
    $gaSql['server'] = "localhost";

    /* REMOVE THIS LINE (it just includes my SQL connection user/pass) */
    // include( $_SERVER['DOCUMENT_ROOT']."/datatables/mysql.php" );


    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    * If you just want to use the basic configuration for DataTables with PHP server-side, there is
    * no need to edit below this line
    */

    /*
    * MySQL connection
    */
    $gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
    die( 'Could not open connection to server' );

    mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
    die( 'Could not select database '. $gaSql['db'] );


    /*
    * Paging
    */
    $sLimit = "";
    if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
    {
    $sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
    mysql_real_escape_string( $_GET['iDisplayLength'] );
    }


    /*
    * Ordering
    */
    if ( isset( $_GET['iSortCol_0'] ) )
    {
    $sOrder = "ORDER BY ";
    for ( $i=0 ; $i $iFilteredTotal,
    "aaData" => array()
    );

    while ( $aRow = mysql_fetch_array( $rResult ) )
    {
    $row = array();
    for ( $i=0 ; $i
    [/code]
This discussion has been closed.