【问题标题】:ngTable nested fieldsngTable 嵌套字段
【发布时间】:2014-11-24 13:27:09
【问题描述】:

我见过 this question 并且解决方案非常简单,但是 this plunker 似乎不适用于我在项目中使用的 Angular 1.33。

这里是 the same plunker 的问题(仅将 Angular 更新到版本 1.33)。

HTML

  <table ng-table="tableParams" show-filter="true" class="table">
    <tr class='listing' ng-repeat="invoice in $data">
      <td data-title="'Invoice No.'" sortable="'no'" filter="{'no':'text'}">
        {{invoice.no}}
      </td>
      <td data-title="'Date'" sortable="'date'" filter="{'date':'text'}">
        {{invoice.date}}
      </td>
      <td data-title="'Client'" sortable="'client.fullname'" filter="{'client.fullname':'text'}">
        {{invoice.client.fullname}}
      </td>
    </tr>
  </table>

【问题讨论】:

  • 如果您从过滤器中删除 .fullname ,它将使用有效的对象的所有属性(我认为)。这会给您带来其他问题吗?
  • @DoctorMick 我知道...但我需要full_name 列不仅可搜索...而且如果我删除属性我将无法在多个字段中搜索在user 嵌套对象中。
  • 过滤器语法似乎已更改为使用正确的 JSON 表示法:github.com/angular/angular.js/issues/6222。我的猜测是 ngTable 没有相应地更新。
  • 是的,我想是的。.dotted 字符串解析不正确
  • stackoverflow.com/a/26741658/4104866 看看,ngtable 根本不解析点

标签: angularjs ngtable


【解决方案1】:

使用排序和过滤器,ngtable 0.3.1 - plunk

<table ng-table="tableParams" show-filter="true" class="table">
    <tr class='listing' ng-repeat="invoice in $data">
      <td data-title="'Invoice No.'" sortable="'no'" filter="{'no':'text'}">
        {{invoice.no}}
      </td>
      <td data-title="'Date'" sortable="'date'" filter="{'date':'text'}">
        {{invoice.date}}
      </td>
      <td data-title="'Client'" sortable="'client.fullname'" filter="{'client':'text'}">
        {{invoice.client.fullname}}
      </td>
    </tr>
  </table>

【讨论】:

  • Thanx Kositia 您的解决方案按预期工作......但我希望是否有能力过滤多个嵌套字段......现在这对我来说已经足够......再次感谢。
  • @MohammadWalid 我很高兴为您提供帮助,所以您想过滤客户端对象的所有道具,对吗?这对我来说也很有趣,我会对此进行一些研究并回来)))
猜你喜欢
  • 1970-01-01
  • 2014-07-12
  • 1970-01-01
  • 2011-08-07
  • 1970-01-01
  • 1970-01-01
  • 2019-01-15
  • 2016-11-26
  • 1970-01-01
相关资源
最近更新 更多