Skip to content

Find or Select by Row Entity's 'ID' #4457

@nkoterba

Description

@nkoterba

Our dataset, as I'm sure many others also use, has an ID for records, let's call this field: id

In our web application, instead of passing around entire entities, we just pass the ids of these records.

NOTE: Our grids do not display the ID column so our columnDefs does not include this column. Perhaps including this column and making the column hidden would allow faster selection/searching? But then we are also adding potentially many unnecessary DOM elements to the GRID.

What's the most efficient way to find a grid row for selection using an id.

The only way I can think of achieving this is by:

  1. Iterate through $scope.gridOptions.data looking for item
  2. Call $scope.gridApi.selection.selectRow(rowEntity, event) passing in item found in step 1 for rowEntity.

However, I'm not sure if there's a more efficient way (using grid hashing maybe)?

In some instances, I get an array of IDs to select. So I would have to loop through the above pseudo-code for each ID in IDs, which would create an O(n^2) operation. I was hoping there would be something more performant.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions