【问题标题】:Set Tabulator Title and Field values Dynamically from Json response从 Json 响应中动态设置制表符标题和字段值
【发布时间】:2019-05-14 09:13:50
【问题描述】:

我正在使用 Tabulator 4.1,我有从 ajax 返回的 json 响应,因此我必须在 tabulator 中显示值。这里的问题是每次都更改了包含的 json 数据(即)

[{
    "AGENCYID": "-1",
    "TOTALREQUEST": 1
},
{
    "AGENCYID": "-1",
    "TOTALREQUEST": 2
}]

这里的键和值可能会增加。因此,相应地在制表器中显示这些值,我尝试在制表器中动态设置标题和归档值,但没有任何效果。下面我附上了 JS fiddle

https://jsfiddle.net/harifrais/vzxt1r4e/15/

【问题讨论】:

标签: json tabulator


【解决方案1】:

请修复你的 Js fiddle 网址

var jsonres = [
	{
		"AGENCYID": "-1",
		"TOTALREQUEST": 1
	},
	{
		"AGENCYID": "-1",
		"TOTALREQUEST": 2
	},
	{
		"AGENCYID": "-1",
		"TOTALREQUEST": 3
	}
];






var table = new Tabulator("#example-table", {
  data: jsonres, //load row data from array
  autoColumns: true

});
<!DOCTYPE html>
<html lang="en">

<script src="https://unpkg.com/tabulator-tables@4.2.4/dist/js/tabulator.min.js"></script>
<link href="https://unpkg.com/tabulator-tables@4.2.4/dist/css/tabulator.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<body>
  <div id="example-table"></div>
</body>

</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多