Reference to Grid Cell in CellRender function

1 Answer 1063 Views
Grid
Mo
Top achievements
Rank 1
Iron
Mo asked on 29 Jul 2021, 06:02 AM | edited on 29 Jul 2021, 06:03 AM

When the cellRender function is called from Kendo Grid, are we able to access the ref on the tdElement that is passed as a parameter? I seem to be getting null when trying to access ref. I had thought we are able to access ref on any Kendo component.

I am trying to access the ref because I would like to check if the textContent is overflowing and show a tooltip if it is. I was able to get this done by cloning the tdElement and passing in a custom ref but trying to see if there is a simpler way. Thank you! 

 

https://www.telerik.com/kendo-react-ui/components/grid/api/GridProps/#toc-cellrender

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 02 Aug 2021, 04:25 AM

Hello, Mo,

In this demo, we are using the ref of the td, please advise if it is not working in the real application:

https://www.telerik.com/kendo-react-ui-develop/components/grid/editing/editing-in-cell/

 

Regards,
Stefan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Mo
Top achievements
Rank 1
Iron
commented on 02 Aug 2021, 07:00 PM

Hi Stefan,

If I was to access td.ref in `customCellRender` , it would be null. 


 const customCellRender = (td, props) => {
    console.log(td.ref)
    return <CellRender originalProps={props} td={td} enterEdit={enterEdit} editField={editField} />;
  }

 

Thank you!

Stefan
Telerik team
commented on 03 Aug 2021, 05:24 AM

This is expected as in that case, the cell is directly rendered by the developer and we have no access to it. In those cases, we recommend executing the same logic inside the custom cell, not inside the cellRender.

Executing it inside the cellRender is still possible by using the approach shown in this forum post:

https://www.telerik.com/forums/custom-editor-that-works-with-example-pattern-for-onclick-renders-edit
Mo
Top achievements
Rank 1
Iron
commented on 04 Aug 2021, 03:36 AM

Thank you Stefan.
Tags
Grid
Asked by
Mo
Top achievements
Rank 1
Iron
Answers by
Stefan
Telerik team
Share this question
or