在js中如何在dataTable中动态的绑定数据
<scripttype="text/javascript"language="javascript"class="init">vararr=[{name:"fxf",po...
<script type="text/javascript" language="javascript" class="init">
var arr = [
{ name: "fxf", position: "China", office: "hubei", age: 23, startday: "1991 /10 /19", salary: "¥5000" },//json
{ name: "jk", position: "China", office: "hubei", age: 23, startday: "1991 /10 /19", salary: "¥5000" },
{ name: "zz", position: "China", office: "hubei", age: 21, startday: "1991 /10 /19", salary: "¥5000" },
{ name: "cl", position: "China", office: "hubei", age: 22, startday: "1991 /10 /19", salary: "¥5000" },
{ name: "fy", position: "China", office: "hubei", age: 16, startday: "1991 /10 /19", salary: "¥5000" },
{ name: "fh", position: "China", office: "hubei", age: 18, startday: "1991 /10 /19", salary: "¥5000" },
{ name: "cq", position: "China", office: "hubei", age: 23, startday: "1991 /10 /19", salary: "¥5000" },
{ name: "wq", position: "China", office: "hubei", age: 20, startday: "1991 /10 /19", salary: "¥5000" }
];
$(document).ready(function () {
$("#example").dataTable({
"bPaginate":true,
"bInfo": true,
"bPaginationType":"full_numbers",
"columns": ["name","position","office","age","startday","salary"],
"data": arr,
"order": [[1, 'asc']]
});
});
</script>
使用这段代码 数据绑定不进去 展开
var arr = [
{ name: "fxf", position: "China", office: "hubei", age: 23, startday: "1991 /10 /19", salary: "¥5000" },//json
{ name: "jk", position: "China", office: "hubei", age: 23, startday: "1991 /10 /19", salary: "¥5000" },
{ name: "zz", position: "China", office: "hubei", age: 21, startday: "1991 /10 /19", salary: "¥5000" },
{ name: "cl", position: "China", office: "hubei", age: 22, startday: "1991 /10 /19", salary: "¥5000" },
{ name: "fy", position: "China", office: "hubei", age: 16, startday: "1991 /10 /19", salary: "¥5000" },
{ name: "fh", position: "China", office: "hubei", age: 18, startday: "1991 /10 /19", salary: "¥5000" },
{ name: "cq", position: "China", office: "hubei", age: 23, startday: "1991 /10 /19", salary: "¥5000" },
{ name: "wq", position: "China", office: "hubei", age: 20, startday: "1991 /10 /19", salary: "¥5000" }
];
$(document).ready(function () {
$("#example").dataTable({
"bPaginate":true,
"bInfo": true,
"bPaginationType":"full_numbers",
"columns": ["name","position","office","age","startday","salary"],
"data": arr,
"order": [[1, 'asc']]
});
});
</script>
使用这段代码 数据绑定不进去 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询