New line breaks in grid column

3 posts, 1 answers
  1. timmy
    timmy avatar
    41 posts
    Member since:
    Dec 2006

    Posted 24 Jan 2017 Link to this post

    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. Answer
    Niko
    Admin
    Niko avatar
    404 posts

    Posted 26 Jan 2017 Link to this post

    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.
  3. timmy
    timmy avatar
    41 posts
    Member since:
    Dec 2006

    Posted 26 Jan 2017 in reply to Niko Link to this post

    Niko,

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

    Tim

Back to Top