ui-grid: Filtering doesn't work when fields are object properties

Filtering doesn’t seem to work when the data in the grid consists of nested objects. For example, suppose you have data that looks like this:

$scope.myData = [{fields: {name: "Moroni", age: 50}},
                 {fields: {name: "Tiancum", age: 43}},
                 ...];

You can configure the column definitions so that the data displays properly in the grid:

columnDefs:[
  {
    field: "fields['name']",
    displayName: "Name"
  },
  ...
]

… but any attempts at filtering with the search box will result in no items showing in the grid. Presumably this is because ng-grid filters strings, not objects. Is there a way to get filtering to work in such a case? Here’s a Plunker demonstrating this example: http://plnkr.co/edit/l2J1S9

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 25 (7 by maintainers)

Commits related to this issue

Most upvoted comments

The square brackets don’t seem to work. Funnily enough the array can be accessed using dots. Instead of:

field: 'level2array[0].value'

try:

field: 'level2array.0.value'

http://plnkr.co/edit/r6Ezse?p=preview

filtering is now working for just the first column ‘level2array.0’ - hmmn not much better. I think you will need to change your json structure to really make this work…