渲染动态表格以错误的顺序显示单元格内容
我正在尝试渲染一个带有动态标题的表格,并用对象数组填充它,目标是对齐填充有与标题同一列中的对象属性的单元格。
header是一个字符串数组,每个字符串对应一个对象属性,这样字符串的值就等于对象属性。
每个对象不一定包含表头作为属性。这是我到目前为止所得到的:
<table>
<thead>
<tr>
<th
v-for="header in activeTableHeaders"
:key="header"
scope="col"
>
<p>
{{ header }}
</p>
</th>
</tr>
</thead>
<tbody>
<tr v-for="(dataItem, outerIndex) in renderableResults" :key="outerIndex">
<td v-for="(key, innerIndex) in activeTableHeaders" :key="innerIndex">
{{ dataItem[key] }}
</td>
</tr>
</tbody>
</table>
这是所显示内容的裁剪不当的图像:
这是问题所在:当我过滤数据时,例如: renderableResults.value = renderableResults.value.filter(doc => doc['ledv'] >= 200);
然后记录结果,我可以看到结果正确地包含了所有结果'ledv'属性小于200的已被过滤掉。
然而,表列仍然包含小于 200 的值:
我正在处理大量结果,因此我很难找出错误值的来源,我设法在第一行中找到“190”的值来自 lsv 而不是 ledv。
知道出了什么问题吗?我自己似乎无法弄清楚,我真的被困住了。
activeTableHeaders
如下所示:
这是 renderableResults
尽管看起来第一个结果是renderableResults
不是第一个要渲染的结果,很奇怪。
先感谢您!任何帮助将不胜感激!
I'm trying to render a table with dynamic headers, and populating it with an array of objects, the goal is to align the cells filled with the object properties in the same column as the header.
The header is an array of strings, and each string corresponds to an object property, such that the value of the string is equal to the object property.
Each object does not necessarily contain the table header as a property. Here's what I've got so far:
<table>
<thead>
<tr>
<th
v-for="header in activeTableHeaders"
:key="header"
scope="col"
>
<p>
{{ header }}
</p>
</th>
</tr>
</thead>
<tbody>
<tr v-for="(dataItem, outerIndex) in renderableResults" :key="outerIndex">
<td v-for="(key, innerIndex) in activeTableHeaders" :key="innerIndex">
{{ dataItem[key] }}
</td>
</tr>
</tbody>
</table>
Here's a poorly cropped image of what's displayed:
Here's what goes wrong: When I filter the data, e.g:renderableResults.value = renderableResults.value.filter(doc => doc['ledv'] >= 200);
and then log the results, I can see that the results have correctly had all results with the property of 'ledv' less than 200 been filtered out.
Yet, the table columns still contain values less than 200:
I'm handling a lot of results so it was hard for me to track down where the incorrect values are coming from, I managed to find in the first row, the value of '190' is coming from lsv
not ledv
.
Any idea what's going wrong? I can't seem to figure it out myself and I'm truly stuck.
Here's what activeTableHeaders
looks like:
Here's the first result from renderableResults
although it appears that the first result in renderableResults
isn't the first result to be rendered, strange.
Thank you in advance! Any help will be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是,虽然我正确过滤了结果,但渲染的结果也是分页的,我忘记更新分页结果
Issue was that although I was filtering the results correctly, the results that are rendered are also paginated, I forgot to update the paginated results