views:

45

answers:

3

hi all.. i have a problem,,i try to make a table using datatable...i've been download from datatable.net.. but the data grid not show...just the table head (thead)... where is my fault??

<table cellpadding="0" cellspacing="0" border="0" class="display" id="datalist">
       <thead>
             <tr>
                 <th>Line </th>
                 <th>Model </th>
                 <th>Serial </th>
                 <th>NIK </th>
             </tr>
       </thead>
       <tbody> </tbody>
</table>

<script>
$(document).ready(function(){
       var oTable;
       oTable = $("#datalist").dataTable({
             "bRetrieve"  : true,
             "bServerSide": true,
             "bProcessing": true,
             "sAjaxSource": 'showlist.php',
             "aaSorting"  : [[1,"desc"]],
             "aoColumns"  : [
                             /*Line*/  null,
                             /*Model*/ null,
                             /*Serial*/null,
                             /*NIK*/   null
                            ]
             });
       });
</script>

at firebug not show error and at post response show result:

 {"aaData":[
               ["FA 04","KW-XC555UD","123X0098","12345"],
               ["FA 05","KD-R435UHD","113X0057","12345"],
               ["FA 11","kd-r411uhd","115x0021","12345"],
               ["FA 04","kw-xc406hund","105x1101","12345"],
              ]}          
A: 

I look at the xhr returned value (of the sample) and it turned out has a pattern like this,

{"sEcho": 1, "iTotalRecords": 57, "iTotalDisplayRecords": 57, "aaData": [ ["Gecko", ....

try it in yours and let see if it fixes it...

Reigel
is this code are put at showlist.php?
klox
that JSON is what the sample page returned in their php... your showlist.php must also return something like that... you can see how to do that here http://datatables.net/examples/server_side/server_side.html
Reigel
A: 

i've been use this code:

$rResultTotal = mysql_query( $sQuery) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($sql) . '</small>): ' . mysql_error() );  // submit SQL to MySQL an$
        $aResultTotal = mysql_fetch_array($rResultTotal);
        $iTotal = $aResultTotal[0];

        $sOutput = '{';
        $sOutput .= '"sEcho": '.intval($_POST['sEcho']).', ';
        $sOutput .= '"iTotalRecords": '.$iTotal.', ';
        $sOutput .= '"iTotalDisplayRecords": '.$iFilteredTotal.', ';
        $sOutput .= '"aaData": [ ';
        while ( $aRow = mysql_fetch_array( $rResult ) )
        {
                $sOutput .= "[";
                $sOutput .= '"'.addslashes($aRow['Line']).'",';
                $sOutput .= '"'.addslashes($aRow['Model']).'",';
                $sOutput .= '"'.addslashes($aRow['Serial_number']).'",';
                $sOutput .= '"'.addslashes($aRow['NIK']).'"';
                $sOutput .= "],";
        }
        $sOutput = substr_replace( $sOutput, "", -1 );
        $sOutput .= '] }';

        echo $sOutput;
klox
A: 

Hi! I've had similar problem and decided it by this way: 1) downloaded new version of datatables-1.7 from this site (http://datatables.net); if this wil not help - 2) try to look through your data in table of your database which you trying to use with datatables. Use any utulity for manipulating with databases. Pay attention to records if there are any wrong symbols in the ends of data in some cells like symbols of paragraph etc. If any - try to remove them from data. Then it must work. Good luck.

alexqunetin
sometimes after download datatable files become corrupted.i'm using "1.6".after that i redownload that files.and my project can work normally.
klox