Skip to content

No mechanism to bind column to the row object itself #5359

@StrangelyTyped

Description

@StrangelyTyped

Occasionally I find I need a grid with just one column, and often I find that the data I need to bind to it is just an array of strings. I've tried a few different things and haven't been able to find a mechanism to populate a grid from an array of strings without reformatting the data into an array of objects (each with a single property - the original string for that row).

Attempting to do so results in a grid with the correct number of rows but no content in the specified column, as you can see in my example plunk here

Omitting the field column property altogether or providing an empty value, or passing other possible values like 'row' result in an empty cell.

The ui-grid documentation says that the 'field' property "Should be an angular expression that evaluates against grid.options.data array element." and to "See the angular docs on binding expressions.". The angular docs specify this in a section on the expressions page - "It is possible to access the context object using the identifier this", however using 'this' as the field value does not appear valid either, resulting in an empty cell as well.

As a result I have yet to find a mechanism for using an array of strings as source data for a UI Grid. I'd like to request that such functionality be added, possibly through a special value in the column's field property ('this' or empty string would appear to be good candidates, the latter being my preference). If such a mechanism already exists and I simply haven't found it then I'd like to request that the documentation be updated to provide examples of how this is done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions