Search code examples
asp.net-mvctelerikkendo-ui

Html new lines in kendo grid


I have a kendo grid in mvc with column property .Encoded(false) In the controller I replaced Environment.NewLine with

 <br>

But in the view there is a text instead of real new line. I tried both:

 <br> or <br/>

It is not working either. What am I doing wrong?


Solution

  • Finally I solved it myself. in the Grid:

    columns.Bound(m => m.Address).Width(150).Encoded(false).ClientTemplate("#= getHtmlNewLinesString(Address) #");
    

    and in the js:

     function getHtmlNewLinesString(text) {
            var regexp = new RegExp('\n', 'g');
            return text.replace(regexp, '<br>');
        }