Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

Custom React components in Table rows? #364

Open
tirdadc opened this issue Mar 3, 2017 · 4 comments
Open

Custom React components in Table rows? #364

tirdadc opened this issue Mar 3, 2017 · 4 comments

Comments

@tirdadc
Copy link

tirdadc commented Mar 3, 2017

I figured this would allow me to include my own custom components (in this case a customized input defined as TextField) in the Table, but I get this error and the rows do not render:

The only possible children of <Table> are <Thead>, <Tr>, or one <Tfoot>.

Is there no way to use this with other components at this point?

@rickysahu
Copy link

Yup, i have this same issue, it makes managing more complex code difficult.

@ssorallen
Copy link

ssorallen commented May 25, 2017

How would you expect sorting and filtering to work for those elements?

@rickysahu
Copy link

the simplest way that comes to mind is getting the entire text content of the component and using that as a string value. if all values can be parsed as float / numeric, then sort / filter as numeric.

@enriquejosepadilla
Copy link

I had rows that had to hold array values and then since i didnt use the data prop sorting/filtering didnt work. Since my Tr wrapped my div i used the following for the sorting.

//We have to deconstruct the DIV array that we made
const arraySort = (a, b) => {
    const valuesA = a.props.children[0];
    const valuesB = b.props.children[0];

    if (valuesA.length === 0) {
        return 1;
    }
    if (valuesB.length === 0) {
        return -1;
    }

    //for some reason the array haves empty values with the "real" value
    const realA = valuesA[0].props.children.find(v => v !== ' ');
    const realB = valuesB[0].props.children.find(v => v !== ' ');

    return realA.localeCompare(realB);
};

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

No branches or pull requests

4 participants