[英]How to add data for new column in Tabulator.js?
I have a simple table where the main data logic is about columns, not row.我有一个简单的表,其中主要数据逻辑是关于列的,而不是行。 The table is about displaying and comparing test results.该表用于显示和比较测试结果。 The test got about 40 different results (=rows).测试得到了大约 40 个不同的结果(=行)。 A test is represented by a column.测试由一列表示。 I need to add new test results on the fly.我需要即时添加新的测试结果。
I have this part working but adding new column table.addColumn
and updating the whole table data table.setData(
我有这部分工作但添加新列table.addColumn
并更新整个表数据table.setData(
I wonder whether我不知道是否
If you want to update all the rows in the table at once you can use the updateData
function, you pass in an array of row objects, each object must contain the row index field and the field for the column you want to add.如果你想一次更新表中的所有行你可以使用updateData
function,你传入一个行对象数组,每个object必须包含行索引字段和你要添加的列的字段。
So say for example I had a table with three rows, the index for each column was the id
field and the new field is name
:例如,我有一个包含三行的表,每列的索引是id
字段,新字段是name
:
table.updateData([
{id:1, name:"steve"},
{id:2, name:"bob"},
{id:3, name:"jim"},
]);
This would add the data to the rows but would not display it, so we would then need to add the name
column to the table using the addColumn
function:这会将数据添加到行但不会显示它,因此我们需要使用addColumn
function 将name
列添加到表中:
table.addColumn({title:"Name", field:"name"});
to display a new column in the table you would nee要在表格中显示一个新列,您需要
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.