search is not working in jquery datatables with dynamically populated table

search is not working in jquery datatables with dynamically populated table

harpalharpal Posts: 2Questions: 2Answers: 0
edited January 2015 in Free community support

I am having trouble with datatable search ,even though data is present in datatable search always shows "No matching records found" . I am using jquery datatable plugin. I am populating some column's data dynamically and creating some columns for user to input some data later on .

Here is the snippet of my code : -

<script src="media/js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script src="media/js/jquery.dataTables.js"></script>
    <link href="media/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script src="extensions/Plugins/integration/bootstrap/3/dataTables.bootstrap.js"></script>
    <link rel="stylesheet" href="css/bootstrap-multiselect.css" type="text/css">
    <script type="text/javascript" src="js/bootstrap-multiselect.js"></script>
    <link rel="stylesheet" href="css/bootstrap-theme.min.css">

<script>
$(document).ready(function() {
    $('#dbResultsTable').dataTable( {
        "bJQueryUI": true,
        "sPaginationType": "full_numbers" ,
        "paging":   true,
        "ordering" : false,
        "scrollY":false,
        "autoWidth": true,
        "info":     true ,
       "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
       "dom": '<"top"iflp<"clear">>rt<"bottom"iflp<"clear">>' 
        }
         );
        $('.companyNamesClass').multiselect({
            enableFiltering: true
        }),
           $('#dbResultsTable').on('draw.dt', function () {
            $('.companyNamesClass').multiselect({
                 enableFiltering: true,
            });
        });
    });
</script>
<body>
    <table width="1698" cellspacing="0"  class="elements" id="dbResultsTable" >
      <thead>
        <tr bgcolor="#33FFFF">
    <th>Student</th>
    <th>BranchName</th>
    <th>Year</th>
    <th>Company</th>
    <th>Pkg</th>
    </thead>
      <tbody>
        <c:forEach var="indexMap" items="${requestScope.studentMap}">
           <tr><td><input type="textbox" value="${indexMap.key}"></td>
               <td><input type="texbox" value="${resultMap.value}"></td>
                <td>2010</td>
                <td>
                <select name="compnayNames[]"  class="companyNamesClass" multiple="multiple">
                    <option value="Apple">Apple</option>
                    <option value="Google">Goolge</option>
                    <option value="Tata">Tata</option> 
                    <option value="IBM">IBM</option>
                    <option value="Other">Others</option>
              </select>
                </td>
                    <td><input type="textbox"></td> 
            </tr>
        </c:forEach>                                                
        </tbody>
</table>
</body>
This discussion has been closed.