0
votes

I have a multi-line text in one of the cells in kendo grid. Kendo template works fine for simple text but not for text which have a new line or next line(\n) or multi-line. There might be some problem in template code.

Here is the edit template in grid

 { field: "", title: "Action", sortable: true, headerTemplate: createHeaderTemplate1("Action"),
 template: '<a  onclick="EditStatus(${StatusId},${ReasonId},${EmployeeId},&quot;${Description}&quot;, &quot;${DescriptionDate}&quot;)"  
 class="tdEdit margin-right10" title="Edit">Edit</a>' }

Below function gets called in all the cases except if Description field in the grid have multi-line.

function EditStatus(StatusId,ReasonId,EmployeeId ,Description,DescriptionDate)
{
  // to Do
}

How multiline text it appears in fire bug:

<a onclick="EditStatus(50162, 2,27,&quot;This is new comment to test.
But we need to check difference between space and enter.
Here and then save it.&quot;, &quot;Sat Jun 10 2017 00:00:00 GMT+0530 (India Standard Time)&quot;)" class="tdEdit margin-right10" title="Edit">Edit</a>

whereas in the case when there is no multiline, it works fine and it shows like below in browser

<a onclick="EditStatus(50157, 1,27,&quot;hi&quot;, &quot;Mon Jun 05 2017 00:00:00 GMT+0530 (India Standard Time)&quot;)" class="tdEdit margin-right10" title="Edit">Edit</a>
1
At what point do you experience the problem? When description is multi-lined and "Edit" is clicked? - Shai
The above template works fine for editing a row in kendo grid. But suppose one row is having description field which is a multi-line text i.e user saved it using enter key. For that instance, "EditStatus" function does not gets called and its due to character literal. I think the string which is getting set automatically is not able to judge the new line in it. Please see the difference b/w both edit template. It works fine if it only have text "hi" but it does not work if it have a text with new line like"This is new comment to test. But we need to check difference between space and enter." - Sweetie
I'm asking when do you get the error message? Is it when you click "Edit"? - Shai
yes. you are right. When Description is multi-lined and Edit is clicked then the "Edit Status" function does not get called and chrome says "Invalid or unexpected token". Where as firefox says ":unterminated string literal" - Sweetie

1 Answers

2
votes

Try this:

template: '<a  onclick="EditStatus(${StatusId},${ReasonId},${EmployeeId},`&quot;${Description}&quot;`, &quot;${DescriptionDate}&quot;)" class="tdEdit margin-right10" title="Edit">Edit</a>'

I added backticks (`) to enclose the Description argument.