Sweetie
Sweetie

Reputation: 1368

How to fix Unterminated string literal in kendo grid template

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>

Upvotes: 0

Views: 967

Answers (1)

Shai
Shai

Reputation: 3872

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.

Upvotes: 2

Related Questions