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

New line breaks in grid column

2 Answers 964 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Danny
Top achievements
Rank 1
Danny asked on 24 Jan 2017, 06:39 PM

Hi,

I'd like my text column to recognise line breaks. I've seen this post:

http://www.telerik.com/forums/line-breaks-in-grid-data

but I'm displaying the column using the following format:

columns.Bound(c => c.NoteContent).Title("Note").Width(300);

How would I modify the content so that it replaces '\n' with '<br>'?

Thanks

Tim

2 Answers, 1 is accepted

Sort by
0
Accepted
Niko
Telerik team
answered on 26 Jan 2017, 12:51 PM

Hello Tim,

Please, check the following help article that focuses on defining ClientTemplates for MVC Grid - http://docs.telerik.com/aspnet-mvc/helpers/grid/configuration#clienttemplate. Following the response from the forum post that you mentioned, you could define the client template through:

columns.Bound(c => c.NoteContent).ClientTemplate("#= changeNewLine(data.NoteHtml) #").Title("Note").Width(300);

Hope this helps.

Regards,
Niko
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Danny
Top achievements
Rank 1
answered on 26 Jan 2017, 01:22 PM

Niko,

Sorry, I didn't realise it was that straight forward to use the client templates. Works a treat. Thank you.

Tim

Tags
Grid
Asked by
Danny
Top achievements
Rank 1
Answers by
Niko
Telerik team
Danny
Top achievements
Rank 1
Share this question
or