Skip to content

Match table data columns to column options #209

Open
@phynweb

Description

@phynweb

@shaehn I'd like to suggest a small change to the table.js code, specifically in the code block below

`if (!options.columns || options.columns.length !== fields.length) {
        order = fields; // all fields emitted, columns in order of first record
    } else {
        // columns in order found in options
        for (const column of options.columns) {
            order.push(column.name);
        }
    }`

The impact of || options.columns.length !== fields.length is that if i have an object with say 8 keys, but I only want to create a table with 5 columns (i.e. 5 keys), I have to create a separate objectwhere i've extracted just the 5 keys I'd like to display. If i stick with my original object, I get 3 more columns that are unformatted since I haven't passed any column options for them.

For my use-case, it is quite trivial to create another object. However, I am toying around with adding hyperlinks using a combination of hummusRecipe and hummusJS directly. Hence, I need the data to contain other data not shown in the table i.e. the url. I can also envision a need for extraneous data that shouldn't be displayed passed to the table in events where anything data driven is being done in a table using data that isn't explicitly displayed.

To accomodate this, we would need to change -

if (!options.columns || options.columns.length !== fields.length)

to

if (!options.columns || !options.columns.length)

Please let me know if there's some downstream impact i'm missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions