angularjs
  • ngtable
  • 2014-11-24 144 views 2 likes 
    2

    我看過this question,解決方案非常簡單,但this plunker似乎不適用於我在項目中使用的Angular 1.33。ngTable嵌套字段

    這裏是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> 
    
    +0

    如果從過濾器去除.fullname它會使用所有對象(我的屬性認爲)哪些工作。會導致你其他問題嗎? – DoctorMick 2014-11-24 13:46:00

    +0

    @DoctorMick我知道......但我需要'full_name'列可以排序,不僅可以搜索...如果我刪除了屬性,我將無法搜索'用戶'嵌套對象中的多個字段。 – 2014-11-24 13:48:34

    +1

    它看起來像過濾器語法已更改爲使用適當的JSON表示法:https://github.com/angular/angular.js/issues/6222。我的猜測是ngTable沒有相應地更新。 – DoctorMick 2014-11-24 14:04:13

    回答

    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> 
    
    +1

    Thanx'Kositia'您的解決方案按預期工作......但我希望能夠過濾多個嵌套字段......現在對我來說足夠了......再次感謝。 – 2014-11-25 10:41:48

    +1

    @MohammadWalid我很樂意幫忙,所以你想過濾客戶端對象的所有道具,對吧?,這對我也很有趣,我會對此進行一些研究並返回))) – 2014-11-25 11:47:24

    相關問題