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

DataTable : column name with dot #3548

Closed
Mani-Santhosh opened this issue Nov 1, 2022 · 4 comments · Fixed by #3562
Closed

DataTable : column name with dot #3548

Mani-Santhosh opened this issue Nov 1, 2022 · 4 comments · Fixed by #3562
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@Mani-Santhosh
Copy link

Mani-Santhosh commented Nov 1, 2022

Describe the bug

In the dynamic data table field, the value contains a dot(.) operator that entier the column displayed empty.
eg: { field: "code 2.2", header: "Code 2.2" }
Code 2.2 column displayed empty
image

Reproducer

No response

PrimeReact version

8

React version

18.x

Language

ES6

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

Column name with dot is not showing data

Expected behavior

data would show

@Mani-Santhosh Mani-Santhosh added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 1, 2022
@Mani-Santhosh Mani-Santhosh changed the title Datatable : column name with dot DataTable : column name with dot Nov 1, 2022
@melloware
Copy link
Member

Can you provide a link to your code sandbox please?

@Mani-Santhosh
Copy link
Author

@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Nov 2, 2022
@melloware
Copy link
Member

Thanks for the reproducer confirmed the issue is right here:

static resolveFieldData(data, field) {
        if (data && Object.keys(data).length && field) {
            if (this.isFunction(field)) {
                return field(data);
            } else if (field.indexOf('.') === -1) {
                return data[field];
            } else {
                let fields = field.split('.');
                let value = data;

                for (var i = 0, len = fields.length; i < len; ++i) {
                    if (value == null) {
                        return null;
                    }

                    value = value[fields[i]];
                }

                return value;
            }
        } else {
            return null;
        }
    }

melloware added a commit to melloware/primereact that referenced this issue Nov 2, 2022
@melloware melloware self-assigned this Nov 2, 2022
@melloware melloware added this to the 8.7.2 milestone Nov 2, 2022
melloware added a commit to melloware/primereact that referenced this issue Nov 2, 2022
@Mani-Santhosh
Copy link
Author

Thanks @melloware

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants