简体   繁体   English

空表格单元格

[英]Empty table cells

I got an array with data. 我有一个包含数据的数组。 Now I'm dynamically creating a html table with AngularJS. 现在我用AngularJS动态创建一个html表。

The data in the array is displayed, but there are also empty strings in the two dimensional array, like: 显示数组中的数据,但二维数组中也有空字符串,如:

array = [[""],["name"],[""],["name2"]]

Is there a way to display the empty table cells? 有没有办法显示空表格单元格?

Like this my table data is shifted. 像这样我的表数据被移动了。

If it helps: 如果它有帮助:

var template = `
  <table class="objList" >
    <tr data-ng-repeat="z in colStorageItems | orderBy: \'-name\' track by $index">
      <th class = "col" data-ng-repeat="y in z | orderBy: \'name\' track by $index">
        {{y}}
      </th>
    </tr>
  </table>
`;

Thanks 谢谢

You can use an if ng-if to filter empty items/rows out of the rendered html. 您可以使用if ng-if从渲染的html中过滤空项目/行。

<tr ng-repeat="item in items " ng-if="item.dataField">
   <!-- Content of tr, item.dataField is not not "empty"-->
</tr>

The problem is that HTML table by default doesn't show empty cells. 问题是HTML表默认不显示空单元格。 You can work around the problem using the css attribute empty-cells . 您可以使用css属性empty-cells解决问题。

For example in your page you can include a tag style like the following: 例如,在您的页面中,您可以包含以下标记样式:

<style>
    table { empty-cells: show; }
</style>

I hope it helps you, bye. 我希望它可以帮助你,再见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM