Hi
I have below DataTable . I want to use Sorting,Pagelength like settings Centralised thru Class so that it can be used on all DataTables, With the below code i have to write it on every Index.
- $(document).ready(function () {
- $("#tblLocation").dataTable({
- ajax: {
- type: "get",
- url: "/Location/List",
- dataType: "json",
- dataSrc: ""
- },
- paging: true,
- sort: true,
- pageLength: 10,
- searching: true,
- columns: [
- { 'data': 'Id' },
- { 'data': 'Description' },
- { 'data': 'IsActive' },
- {
- "defaultContent": '<button id="btnEdit" type="submit"><i class="fa fa-pencil"></i></button>'
- }
-
-
- ]
- });
- $('body').on('click', '[id*=btnEdit]', function () {
- var data = $(this).parents('tr').find('td');
- var id = data.eq(0).html();
- var description = data.eq(1).html();
- $('[id*=txtId]').val(id);
- $('[id*=txtDescription]').val(description);
- $("#btnAdd").hide();
- $(".modal-title").html("Update");
- $("#btnUpdate").show();
- $('#myModal').modal("show");
- });
- });
Thanks