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

[BUG] Column Name not showing when using Array of Object Descriptors #71

Closed
Tropicalrambler opened this issue Jun 22, 2019 · 2 comments
Closed

Comments

@Tropicalrambler
Copy link

Tropicalrambler commented Jun 22, 2019

Actual Behavior

When creating a datatable in a page on ERPNext, one can specify the column names with the following declaration:

    const options = {
    columns: ['Name', 'Position', 'Country']
}

This works fine.

However, if you wish to use the Array of Object Descriptors method:

const options = {
    columns: [
        {
            name: 'Desired Name',
            id: 'name',
            editable: false,
            resizable: false,
            sortable: false,
            focusable: false,
            dropdown: false,
            width: 32,
            format: (value) => {
                return value.bold();
            }
        },
        ...
    ]
}

The Name does not show up. Nothing is in the column header. No errors on the console show either. Tried with other browsers, and no joy. It must be a bug.

Expected Behavior

Columns defined using Array of Object Descriptors, should show the name simply without any problems.

Source

@agritheory
Copy link

agritheory commented Jun 22, 2019

@Tropicalrambler Alain, don't nest it. It's expecting either a list or an object, not a list of objects.

    columns:  {
            name: 'Desired Name',
            id: 'name',
            editable: false,
            resizable: false,
            sortable: false,
            focusable: false,
            dropdown: false,
            width: 32
            }
 

@Tropicalrambler
Copy link
Author

Thanks Tyler, silly us! We experimented a bit with Mario and we found the following format resolved the issue:

Number 1 We continued passing a list to a "columns" object.

// Create an options object with the columns and data
const options = {
                columns: [column1, column2, column3, column4, column5, column6, column7, column8, column9],
                // data content is defined previously, and not our issue here...
                data: data_content
            }
            // And we create our data table 
            const data_datatable = new DataTable(container, options);

Number 2 However, our declaration for each column object changed to this and worked.
Instead of name, we used "content"

const column8 = {
        content: "Price",
        id: 'price',
        editable: true,
        resizable: true,
        sortable: false,
        focusable: true,
        dropdown: false,
        width: 121
    }

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

No branches or pull requests

2 participants