Skip to content

Commit

Permalink
Section 6 - Loading Datatables
Browse files Browse the repository at this point in the history
  • Loading branch information
bhrugen committed Sep 23, 2021
1 parent e7a74fe commit 13fe8db
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
12 changes: 8 additions & 4 deletions BulkyBookWeb/Areas/Admin/Views/Product/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@
</div>
<br /><br />

<table class="table table-bordered table-striped" style="width:100%">
<table id="tblData" class="table table-bordered table-striped" style="width:100%">
<thead>
<tr>
<th>Title</th>
<th>ISBN</th>
<th>Price</th>
<th>Author</th>
<th>Category</th>
<th></th>
@*<th>Category</th>*@
@*<th></th>*@
</tr>
</thead>
</table>
</div>
</div>

@section Scripts{
<script src="~/js/product.js"></script>
}
19 changes: 19 additions & 0 deletions BulkyBookWeb/wwwroot/js/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var dataTable;

$(document).ready(function () {
loadDataTable();
});

function loadDataTable() {
dataTable = $('#tblData').DataTable({
"ajax": {
"url":"/Admin/Product/GetAll"
},
"columns": [
{ "data": "title", "width": "15%" },
{ "data": "isbn", "width": "15%" },
{ "data": "price", "width": "15%" },
{ "data": "author", "width": "15%" },
]
});
}

0 comments on commit 13fe8db

Please sign in to comment.