material-table icon indicating copy to clipboard operation
material-table copied to clipboard

MaterialTable Dynamic Lookup

Open ameliawalcek opened this issue 6 years ago • 2 comments

I am trying to make the 'lookup' for the editable table dynamic. When I edit the table I want there to be a drop-down with my edit options, and not a blank space. Here are my columns:

    let columns = [
        { title: "Country", field: "country", lookup: formatData(props.crmStore.countries)},
        { title: "Employee", field: "owner" , lookup: formatData(props.crmStore.owners) },
        { title: "Email Type", field: "email_type" , lookup: formatData(props.crmStore.emailTypes)},
    ]

I am storing my data and functions using mobx. The 'formatData' function arranges my data to the correct format:

{1: "Afghanistan",
2: "Albania",
3: "Algeria",
4: "American Samoa",
5: "Andorra",
6: "Angola",
7: "Anguilla",
8: "Antarctica",
9: "Antigua and Barbuda"...}

When the table loads, the countries do not show up, but when I edit the table and use the drop-down, the countries are there. If I do not use the 'look-up' and just have the 'field', the countries render fine. This is my table:

        <div className="client-table">
                <Grid>
                    <MaterialTable
                        title="User data from remote source"
                        columns={columns}
                        data={props.crmStore.clients}
                        options={{
                        }}
                        icons={tableIcons}
                        editable={{
                            onRowUpdate: (newData, oldData) => {
                            },
                            onRowDelete: (oldData) =>
                                new Promise((resolve) => {
                                    props.crmStore.deleteClient(oldData, resolve)
                                }),
                        }}
                    />
            </Grid>
        </div>

ameliawalcek avatar Aug 30 '20 06:08 ameliawalcek

Can you share how your data looks?

Domino987 avatar Aug 30 '20 18:08 Domino987

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

stale[bot] avatar Nov 28 '20 19:11 stale[bot]