If grid is rendered with empty data - it will not render properly even when data is passed
With all the default settings by results property passed if you pass the empty array first then it outputs There is no data to display. and even if you pass the non-empty array as props - the result will be always broken: the header and the body of the table will be missing with only paging bar rendered properly.
To reproduce just try to render this component:
import React, { Component } from 'react';
import Griddle from 'griddle-react';
export default class Ttt extends Component {
constructor() {
super();
this.state = {
data: []
};
}
handleClick() {
this.setState({
data: [
...this.state.data,
{
id: Math.random(),
data: (new Date()).toString()
}
]
});
}
render() {
const { data } = this.state;
return (
<div>
<button onClick={() => this.handleClick()}>add random row</button>
<Griddle
results={data} />
</div>
);
}
}
That happens because the columns settings are only set on Griddle component mount.
I think that it is an extreme limitation and the component should not rely that much on the initial properties passed, but respect properties every render cycle.
Have to second this - I am unable to use Griddle for a streaming dashboard for this reason.
I'm facing this too. Any known fix? This is a deal breaker since I load an empty table, and results later with ajax from a flux Store.
It appears as though, if you have static columns, you can work around this issue by specifying the columns that you plan to display using the "columns" attribute. This should actually render with the proper columns if that attribute has not been set, though, so we'll work on refreshing the column data on render if the columns attribute is not sent in. An example of the columns attribute in use, with creative names:
<Griddle results={fakeData} columns={["Column1", "Column2", "Column3"]} />
Thanks @blkmutt . I found this workaround in another issue and am using that (forgot to update here).
This should no longer be an problem with the latest version of Griddle but please feel free to open a new issue if any trouble is encountered. 👍