Grid: Do not wrap text in cells if column is not big enough

2 Answers 883 Views
Grid GridLayout
Gerald
Top achievements
Rank 1
Gerald asked on 21 Feb 2024, 07:17 AM

I would like to prevent the grid cells from wrapping and increasing the row height.

Instead I just want the text to be cut off and ending with ellipsis. I tried styling with column classes "white-space: nowrap", but that does not work.

Is that possible?

 

Thank you!

2 Answers, 1 is accepted

Sort by
0
Zornitsa
Telerik team
answered on 22 Feb 2024, 12:05 PM

Hi Gerald,

You are on the right track regarding the usage of the 'white-space: nowrap' CSS declaration to achieve the desired behavior. The mentioned styling should be applied to the Grid cells by using the following class selector:

.k-grid .k-table-td {
    white-space: nowrap;
}
 Here is also a StackBlitz example to better illustrate the approach:

Feel free to also check the following article on how to apply custom styles to our components:

https://www.telerik.com/kendo-angular-ui/components/knowledge-base/custom-styles/

Hope this helps. Feel free to reply in case any further questions arise.

Regards,
Zornitsa
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Gerald
Top achievements
Rank 1
commented on 22 Feb 2024, 12:21 PM

Hello Zornitsa!

 

I would like to achieve this result only for specific columns. Is that also possible?

 

BR,

Gerald

0
Zornitsa
Telerik team
answered on 27 Feb 2024, 08:50 AM

Hi Gerald,

The developer can apply the 'white-space: nowrap' CSS styling only for a specific column by using the style property of the corresponding ColumnComponent: 

 <kendo-grid-column [style]="{ 'white-space': 'nowrap' }"  field="ProductName" title="Name"></kendo-grid-column>

Below I am sharing a StackBlitz example that demonstrates this suggestion:

Alternatively, the approach from my previous reply can also be extended to achieve this behavior with the addition of setting a custom class to the particular column:

<kendo-grid-column [class]="'customClass'" field="ProductName" title="Name"> </kendo-grid-column>
.k-grid .k-table-td.customClass {
     white-space: nowrap;
}

Here is also the example updated with the above code:

I hope the provided information is helpful. Let me know if you have more questions on the matter. 

Regards,
Zornitsa
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
Grid GridLayout
Asked by
Gerald
Top achievements
Rank 1
Answers by
Zornitsa
Telerik team
Share this question
or