我想将 Tabulator js 添加到我的 java 项目中。我将 tabulator.min.js、tabulator.min.css 添加到资源文件夹中。之后将这些依赖项添加到我的 html 页面中,作为 readme.md 中的推荐。
<link rel="stylesheet" th:href="@{/css/tabulator.min.css}">
<script type="text/javascript" th:src="@{/js/tabulator.min.js}"></script>
现在我的表格查看了我在 html 页面中的所有元素,但不正确。
在 Tabulator 的文档中是如何创建标题和表格的示例,
var table = new Tabulator("#example-table", {
columns:[
{title:"Name", field:"name", sorter:"string", width:200, editor:true},
{title:"Age", field:"age", sorter:"number", align:"right", formatter:"progress"},
{title:"Gender", field:"gender", sorter:"string", cellClick:function(e, cell){console.log("cell click")},},
{title:"Height", field:"height", formatter:"star", align:"center", width:100},
{title:"Favourite Color", field:"col", sorter:"string"},
{title:"Date Of Birth", field:"dob", sorter:"date", align:"center"},
{title:"Cheese Preference", field:"cheese", sorter:"boolean", align:"center", formatter:"tickCross"},
],
});
但我想在 html 中创建标题,有可能吗?
并将数据从控制器放入服务器端部分,而不是作为
var data = [
{id:1, name:"Oli Bob", age:"12", col:"red", dob:""},
{id:2, name:"Mary May", age:"1", col:"blue", dob:"14/05/1982"},
{id:3, name:"Christine Lobowski", age:"42", col:"green", dob:"22/05/1982"},
{id:4, name:"Brendon Philips", age:"125", col:"orange", dob:"01/08/1980"},
{id:5, name:"Margret Marmajuke", age:"16", col:"yellow", dob:"31/01/1999"},
];