how to reload the table?

how to reload the table?

mondaymonday Posts: 4Questions: 1Answers: 0
edited December 2014 in Free community support

this is my code :

 <form id="searchForm">
                                    <input  name="userName" type="text" >
                                    <input name="trueName" type="text">
                                    <input name="email" type="text">
                                    <input  name="mobile" type="text">
<a  href="#" id="t1">GO</a>
                                </form>
<tableid="dyntable">
                        <thead>
                            <tr>
                                <th class="head0 nosort">
                                    <input type="checkbox" class="checkall" /></th>
                                <th class="head0">userName</th>
                                <th class="head1">trueName</th>
                                <th class="head0">email</th>
                                <th class="head1">mobile</th>
                                <th class="head0">createtime</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
 var table = jQuery('#dyntable').DataTable({
                        "processing": true,
                        "serverSide": true,
                        "lengthChange": false,
                        "searching": false,
                        "destroy": true,
                        "info":true,
                        "retrieve": true,
                        "displayLength": 10,
                        "stateSave": true,
                        "columnDefs": [{
                            "targets": 0,
                            "searchable": false
                        }],
                        "ajax": {
                            "url": "/do.aspx",
                            "type": "POST",
                            "data": function (d) {
                                return jQuery('#searchForm').serializeArray();
                            }
                        },
                        "columns": [{ "data": "ID" }, { "data": "userName" }, { "data": "trueName" }, { "data": "email" }, { "data": "mobile" }, { "data": "createTime" }],
                        "paginationType": "full_numbers"

                    });

jQuery('#t1').on('click', function () {
                    table.ajax.reload();
                });

</scirpt>
when i use table.ajax().reload() or table.draw() ,it can't reload the table . the version is 1.10.4.so how to reload the table? thanks

This question has an accepted answers - jump to answer

Answers

  • mondaymonday Posts: 4Questions: 1Answers: 0
    edited December 2014
     var table = jQuery('#dyntable').DataTable({
                            "processing": true,
                            "serverSide": true,
                            "lengthChange": false,
                            "searching": false,
                            "destroy": true,
                            "info":true,
                            "retrieve": true,
                            "displayLength": 10,
                            "stateSave": true,
                            "columnDefs": [{
                                "targets": 0,
                                "searchable": false
                            }],
                            "ajax": {
                                "url": "/do.aspx",
                                "type": "POST",
                                "data": function (d) {
                                    return jQuery('#searchForm').serializeArray();
                                }
                            },
                            "columns": [{ "data": "ID" }, { "data": "userName" }, { "data": "trueName" }, { "data": "email" }, { "data": "mobile" }, { "data": "createTime" }],
                            "paginationType": "full_numbers"
    
                        });
    
    jQuery('#t1').on('click', function () {
                        table.ajax.reload();
                    });
    
    
  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin

    it can't reload the table

    Why not? It looks fine to me. Can you link to the page (as required in the forum rules) please?

    Allan

  • mondaymonday Posts: 4Questions: 1Answers: 0

    hi ,allan ,thanks for your replies,
    DataTables
    it's my demo page.

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    Answer ✓

    You have server-side processing enabled, but are always returning draw: 1. Either you need to fully implement server-side processing or if you are working with less than 50k records, I would suggest turning it off.

    Allan

  • mondaymonday Posts: 4Questions: 1Answers: 0

    hi,allan.First , thanks for your help.then i have a new question.
    when i use server-side processing , how should i send the "start" and "length" in 1.10.x

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
This discussion has been closed.