Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error on adding column with displayName and without name #3453

Closed
AgDude opened this issue May 7, 2015 · 2 comments · Fixed by #3571
Closed

error on adding column with displayName and without name #3453

AgDude opened this issue May 7, 2015 · 2 comments · Fixed by #3571
Milestone

Comments

@AgDude
Copy link
Contributor

AgDude commented May 7, 2015

When adding columns to the grid, the name property is generated if not already defined. The method which is generating the name is using the displayName to check for duplicates, not the actual name. So adding multiple of the same displayName fails.

I haven't dug into it any deeper, but you can have two instances. When you try to add the third it fails to generate a name, and leaves it undefined (which causes problems later).

http://plnkr.co/edit/0D7qgs?p=preview

As a side note, there are quite a few comments in the code about allowing a blank "name" for backwards compatibility. I think this also actually an important feature to have. Consider the case of grouping and showing different aggregations for different columns, where the user is allowed to chose which columns to add and remove.

@AgDude AgDude changed the title error on adding column with displayName error on adding column with displayName and without name May 7, 2015
@PaulL1 PaulL1 added this to the 3.1 milestone May 16, 2015
@AgDude
Copy link
Contributor Author

AgDude commented May 22, 2015

Here's a quick work around, to set the name before adding a column:

    var columnDef = {...}
      counter = 1;
    columnDef.name = columnDef.field;

    while ( gridApi.grid.getColumn(columnDef.name) ){
      columnDef.name += counter.toString();
      counter++;
    }
    gridOptions.columnDefs.push(columnDef);

AgDude pushed a commit to AgDude/ui-grid that referenced this issue May 23, 2015
When generating unique column names, do not consider the displayName.
Increment column name property only, using the field as the base.
Increment displayName property only if it is auto-generated,
displaying any provided displayName unchanged.

Fixes: angular-ui#3453
AgDude pushed a commit to AgDude/ui-grid that referenced this issue May 23, 2015
When generating unique column names, do not consider the displayName.
Increment column name property only, using the field as the base.
Increment displayName property only if it is auto-generated,
displaying any provided displayName unchanged.

Fixes: angular-ui#3453
@wesleycho
Copy link

Closing, as this issue looks resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants