Sunday, 10 July 2016

Enable Sorting with Jquery DataTable

No comments
Table -

                              <table id="tableView" class="table tablesorter">
                                        <thead>
                                            <tr>
                                                <th class="textLeft">
                                                    email
                                                </th>
                                           </tr>
                                        </thead>
                                        <tbody>
                                            @foreach (var item in @Model.lstPatient)
                                            {
                                                 <tr>
                                                 <td>@item.email</td>
                                                 </tr>
                                             }
                                        </tbody>
                                </table>



JS


@section Scripts
        {
        <script type="text/javascript">

            $(document).ready(function () {
                var mSortingString = [];
                var disableSortingColumn = 4;
                mSortingString.push({ "bSortable": false, "aTargets": [disableSortingColumn] });


                $('#tableView').DataTable({
                    "paging": false,
                    "ordering": true,
                    "info": false,
                    "bFilter": false,
                    "bInfo": false,
                    "aaSorting": [[0, 'desc']]

                });
             });
</script>
 }