136
Views
6
Comments
[Data Grid Web] Datagrid - auto row height
Question
Forge component by OutSystems R&D
41
Published on 14 Dec 2020

Is there any option to set the row height based on the cell contents (auto row height) rather than by setting a fixed row height?

Staff
Rank: #696

Hello Linto Antony,

Thanks for bringing this subject to the discussion.
Right now we don't have a great solution that can actually solve your question.

The DataGrid team is analyzing this topic and we'll get back to you with:

  • What to do to workaround this

We'll update you as soon as we have the answers for you.

Thank you,

Tiago Pereira

Staff
Rank: #696

Hello Linto Antony,

As I mentioned in my previous message, here follows a workaround type of solution.
You will need to include a Web Block containing the method that you want for setting the rows with a dynamic height resulting in something like in the image below: (This block is included in the sample attached)

Inside the Web Block you can see that we have a Javascript block containing the method responsible for formatting the cells inside the grid. We need to define which are the columns that we want to have that behavior. So we need to edit the AdvancedFormat of those columns. Feel free to change the columns according to your needs. 

code: 

"wordWrap: true,
 multiLine: true"

Right now we need to override the method formatItems because we are explicitly defining the height of the rows inside. So in this Web Block I commented that line for you.

Remember that by using this extended feature, the method related to the formattings of the grid will get overwritten. Specifically, the method formatItem.

Hope this sample is useful if you need to extend DataGrid to have the rows with a dynamic height according to the space that the text needs so that it can be fully presented.

DataGridCustomRowHeight.oml

Rank: #12145

Hi Tiago Miguel Pereira, I'm not able to download the OML file that u have shared. Can u please upload it again

Thanks