Hazuan Nazri 0 Junior Poster in Training

Hello guys,

im trying to learn how to use dynamic data table, which means i want to use data table as my searching result table. but i dint know how to make it because when the search result filled in the table, the sort and other "DataTable" function is not working.

html:

<table id="dyntable" class="sortable table table-bordered responsive">
                            <colgroup>
                                <col class="con0" style="align: center; width: 4%" />
                                <col class="con1" />
                                <col class="con0" />
                                <col class="con1" />
                                <col class="con0" />
                            </colgroup>
                            <thead>
                                <tr>
                                    <th class="head0 nosort">No</th>
                                    <th class="head0">Nama</th>
                                    <th class="head1">No IC</th>
                                    <th class="head0">NO Geran</th>
                                    <th class="head1">No Lot</th>
                                    <th class="head1">Alamat</th>
                                    <th class="head1">Kategori Pemilik</th>
                                    <th class="head1">Pengesahan</th>
                                    <th class="head1">Pamer Profil</th>
                                </tr>
                            </thead>
                            <tbody id="tablehasil">                      
                            </tbody>
                        </table>

ajax:

$("#submit").live("click", function() { //trying to use .live & .on
    //....datastring
    $.ajax(
    {
        type: "POST",
        url: "../controller/searching.php",
        data: dataString,
        cache: false,
        success: function(html)
        {
            $("#tablehasil").html(html);
        }
    });
});

searching.php:

while ($rowNegeri=sqlsrv_fetch_array($ResultNegeri))
{
    echo '  <tr class="gradeX">
    <td><div align="center">'.$rowNegeri['U_PIR_ID'].'</div></td>
    <td>'.$rowNegeri['Nama_PK'].'</td>
    <td>'.$rowNegeri['No_KP'].'</td>
    <td>'.$rowNegeri['No_Geran'].'</td>
    <td>'.$rowNegeri['No_Lot'].'</td>
    <td>Negeri: '.$rowNegeri['Negeri'].'<br>Daerah: '.$rowNegeri['Daerah'].'<br>Mukim: '.$rowNegeri['Mukim'].'</td>
    <td>'.$rowNegeri['Status'].'</td>';

    if($rowNegeri['Tahap_Pengesahan'] == 1)
    {
        echo '<td>Telah Disahkan</td>';
    }
    else
    {
        echo '<td>Belum Disahkan</td>';
    }
    echo '<td><center><a href="" class=""><span class="icon-th"></span></center></td>
    </tr>';
}

i hope someone can teach me how to use DataTable, because i cant understand when read it on DataTable website.