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

Dynamic properties starting with a line break are ignored #2845

Closed
falkoschindler opened this issue Apr 7, 2024 · 1 comment
Closed

Dynamic properties starting with a line break are ignored #2845

falkoschindler opened this issue Apr 7, 2024 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@falkoschindler
Copy link
Contributor

Description

Here is a minimum example of a dynamic property controlling the row height depending on the length of the name:

ui.aggrid({
    'columnDefs': [{'field': 'name'}],
    'rowData': [{'name': 'Alice'}, {'name': 'Bob'}],
    ':getRowHeight': 'params => params.data.name.length * 10',
})

The same property is ignored when wrapped with line breaks:

ui.aggrid({
    'columnDefs': [{'field': 'name'}],
    'rowData': [{'name': 'Alice'}, {'name': 'Bob'}],
    ':getRowHeight': '''
        params => params.data.name.length * 10
    ''',
})
@falkoschindler falkoschindler added the bug Something isn't working label Apr 7, 2024
@falkoschindler falkoschindler added this to the 1.4.21 milestone Apr 7, 2024
@falkoschindler falkoschindler self-assigned this Apr 7, 2024
@falkoschindler
Copy link
Contributor Author

The way we converted strings to JavaScript objects couldn't handle leading line breaks:

obj[attr.slice(1)] = new Function("return " + value)();

The function would just return undefined because the line ends after "return". I fixed it by adding brackets:

obj[attr.slice(1)] = new Function(`return (${value})`)();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant