search not working need help please

search not working need help please

jemzjemz Posts: 131Questions: 40Answers: 1

I have serverside processing,but I have problem in searching data in my databel.looks like the search is not working in my code.

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
 
 
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/dataTables.bootstrap.css">
 
    <script src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.dataTables.min.js"></script>
    <script type="text/javascript"  src="js/dataTablesBootstrap.js"></script>
 
 
 
    <script type="text/javascript" charset="utf-8">
 
 
        $(document).ready(function() {
 
                    $('#example').dataTable( {
                        "processing": true,
                        "serverSide": true,
                        "start": 0,
                        "ajax": {
                            url:"querydata2.php"
                        },
                        "columns": [
                            { "data": "id"},
                            { "data": "empno"},
                            { "data": "firstname"},
                            { "data": "lastname"}
 
                        ]
 
                    } );
 
        } );
 
 
 
 
    </script>
 
 
</head>
<body>
<div class="container">
    <table id="example" class="display" cellspacing="0" width="100%">
        <thead>
        <tr>
            <th>ID</th>
            <th>EMPNO</th>
            <th>FIRSTNAME</th>
            <th>LASTNAME</th>
 
        </tr>
        </thead>
 
 
    </table>
</div>
 
 
</body>
</html>

and the data response from the server

{"draw":1,"recordsTotal":406504,"recordsFiltered":406504,"data":[{"id":"10","empno":"000006","firstname":"michelle","lastname":"ang"},{"id":"11","empno":"000007","firsname":"jean","lastname":"shane"},{"id":"12","empno":"000008","firstname":"annie","lastname":"merely"},{"id":"15","empno":"000009","lastname":"jack","lastname":"mack"},{"id":"16","empno":"0000010","firstname":"jill","lastname":"hill"},{"id":"17","empno":"000011","firstname":"matt","lastname":"monroe"},{"id":"18","empno":"000012","firstname":"alex","lastname":"heart"},{"id":"20","empno":"0000013","lastname":"carl","lastname":"jame"},{"id":"21","empno":"0000014","lastname":"kriz","lastname":"foonte"},{"id":"22","empno":"0000015","lastname":"micka","lastname":"andexter"}]}

Thank you in advance

Answers

  • jemzjemz Posts: 131Questions: 40Answers: 1

    I hope someone could help me

  • jemzjemz Posts: 131Questions: 40Answers: 1
    edited October 2014

    I copied the sample here in website it works fine in my localhost but when I use my database the search and sorting column is not working.is this a bug ?

    Thank you in advance.

  • jemzjemz Posts: 131Questions: 40Answers: 1

    I am using datatables 1.10.2

  • jemzjemz Posts: 131Questions: 40Answers: 1

    did I miss something in configuration ?

  • jemzjemz Posts: 131Questions: 40Answers: 1
    edited October 2014

    I thought datatables will automatically search in my table,do I need to make search query in my server side?

    Thank you in advance.

  • jemzjemz Posts: 131Questions: 40Answers: 1

    Hi,I am still new on this datatable,do I need to use the Server-side scripts?I found it here

    https://datatables.net/development/server-side/php_mysql

    In order the search and sorting will be working?

This discussion has been closed.