Angular Material 2 DataTable Sorting with nested objects

前端 未结 11 916
孤街浪徒
孤街浪徒 2020-11-29 17:25

I have a normal Angular Material 2 DataTable with sort headers. All sort are headers work fine. Except for the one with an object as value. These doesn\'t sort at all.

11条回答
  •  猫巷女王i
    2020-11-29 17:43

    It's trying to sort by element['project.name']. Obviously element doesn't have such a property.

    It should be easy to create a custom datasource that extends MatTableDatasource and supports sorting by nested object properties. Check out the examples in material.angular.io docs on using a custom source.

提交回复
热议问题