Material-table: can i get remotedata from detailpanel

Created on 21 Mar 2019  路  4Comments  路  Source: mbrn/material-table

something like this

detailPanel={[
    {
        tooltip: 'xxx',
        render: rowData => {
            return new Promise((resolve,reject)=>{
                fetch(`${MAIN}/v1/xxx?xx=${rowData.xxx}`)
                    .then(response=>response.json())
                    .then(res=>{
                        let {xxx}=res
                        resolve(<div>{xxx}<div/>)
                    })
            })
        },
    },
]}
help wanted

All 4 comments

You can return a new component in detail panel render:

detailPanel={[
    {
        tooltip: 'xxx',
        render: rowData => <YourComponent data={rowData}/>
    },
]}

Then take your data in componentDidMount function of YourComponent

thanks!
it works

I tried this. The detailPanel does not open up. It just opens and closes automatically. How do we render the data received from remote? The render of the CustomComponent gets called before data is received from remote.

@deepatr12 that's true. This issue shouldn't be closed. I am using hooks to fetch stuff and I am certain it does not work and has exactly the same behaviour you are describing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

diegosps picture diegosps  路  3Comments

balibou picture balibou  路  3Comments

jlgreene2 picture jlgreene2  路  3Comments

KKrisu picture KKrisu  路  3Comments

Likurg2010 picture Likurg2010  路  3Comments