E aí, vamos lá. não sei se você conseguiu, mas se alguém precisar disso algum dia, ta aqui:
Obs: Estou me baseando pelo código do @igoralves, então só vou mencionar os arquivos que realmente importam
Link: https://github.com/Igoralves12/Datatableteste/
index.html:
<html>
<head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/util.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.dataTables.min.css" />
<script type="text/javascript" src="data/datatables.min.js"></script>
<title>Produtos</title>
</head>
<body>
<table id="index-produtos" class="display">
<thead>
<tr>
<th>ID</th>
<th>Produto</th>
<th>Preço</th>
<th>Status</th>
</tr>
</thead>
</table>
</body>
</html>
js/util.js:
$(document).ready(function () {
$("#index-produtos").DataTable({
"ajax": "json/produtos.json",
columns: [
{ "data": 'id' },
{ "data": 'name' },
{ "data": 'price' },
{ "data": 'available' }
]
}
);
});
OK, o JSON eu não vou postar todo, só o começo pra vcs terem um norte:
OBS: antes estava como produto, eu mudei pra data
json/produtos.json
{
"data": [
{
"id": 1,
"name": "Jaleco",
"price": "R$ 999,99",
"available": true
},
{
"id": 2,
"name": "Avental",
"price": "R$ 999,99",
"available": true
},
............................