This is a migrated thread and some comments may be shown as answers.

Use HOC for CustomGridDetailRow?

4 Answers 166 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pavel
Top achievements
Rank 1
Pavel asked on 02 Oct 2018, 08:30 PM

Hello,

Is it possible to use functional HOC for CustomGridDetailRow like the one provided in the documentation (below) which is not leading to extra rendering of GridDetailRow?

Or it's a must to use only an instance of React.Component class/GridDetailRow class?

 

class CustomGridDetailRow extends GridDetailRow {

    render() {

        const detailData = this.props.dataItem.MasterField2;

        return (

            <div> This is detail template with another grid inside it <Grid scrollable="none" data={detailData} /></div>

        );

    }

}

 

<Grid data={this.state.data} detail={CustomGridDetailRow} >

    <GridColumn field="MasterField1" />

</Grid>

 

The point is that if I try to use functional HOC inside detail prop (or just a function returning CustomGridComponent) there're some issues with rendering DetailRow (like additional re-rendering during scrolling). It seems that this variable inside detail property should be an instance of React.Component/GridDetailRow class, otherwise Grid component can't perform some internal logic based on lifecycle hooks.

 

Thanks in advance for any response.

4 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 03 Oct 2018, 11:43 AM
Hello, Pavel,

The DetailRow could be set to function HOC.

I used our demo, set the detail row to function instead of React.component and the example is working as expected.

This is the example, if a missed the issue please share a short video of the undesired behavior:

https://stackblitz.com/edit/react-1yvl3e?file=app/main.js

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Pavel
Top achievements
Rank 1
answered on 03 Oct 2018, 12:29 PM

Hi Stefan,

Appreciate your detailed and quick answer, but unfortunately it doesn't really help solve the issue.

If you don't mind please have a look at more specific example here: https://stackblitz.com/edit/react-1yvl3e-y9nsab?embed=1&file=app/main.js I've changed the HOC to make it just a wrapper function that returns the function passing props to Grid component.

Steps to reproduce: expand detailed row, then resize it and right after try to expand another row - the first one doesn't preserve the state and resets the columns width to default value.

0
Accepted
Stefan
Telerik team
answered on 04 Oct 2018, 06:31 AM
Hello, Pavel,

Thank you for the clarification.

The described result is expected because the detail row does not keep the internal state of the columns as it is a functional component that is without a state.

In this case, I can suggest keeping the state of the widths in the parent component and to update them on the resize event. This will persist the widths and it will automatically apply it on the other details Grids.

I made an example demonstrating this:

https://stackblitz.com/edit/react-1yvl3e-veejom?file=app/main.js

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Pavel
Top achievements
Rank 1
answered on 04 Oct 2018, 07:58 AM

Dear Stefan,

 

Again thanks for your reply and provided example. It's now pretty clear the details regarding the GridDetailRow and it's state manipulation.

 

Cheers,

Pavel

Tags
General Discussions
Asked by
Pavel
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Pavel
Top achievements
Rank 1
Share this question
or