简体   繁体   中英

Add line return in Kendo Grid Client Template

I have a Kendo UI grid with a custom column as such:

columns.Template(@<text></text>)
              .Width(50)
              .ClientTemplate("#= getDeleteHTML(Id, DisplayLocation) #");

It calls a js function to build the html to inject as a form to submit for a delete:

function getDeleteHTML(itemId, itemName) {
        var deleteHtml = "<form action='"+ '@Url.Action("Delete", "ManageLocations")'+"/" + itemId +"' method='post'>"
                            + "<input type='image' onclick='return confirm(\"Are you sure you wish to delete: \r\n" + itemName + "?\");' value='Delete' class='delete' src='../Images/transparent.gif'>"
                        + "</form>";
        return deleteHtml;
    }

I want to break the confirmation message into 2 lines. I've tried \\r\\n and @Environment.NewLine + itemName as I'm not sure which parser is being used (client or server) in this case.

How can I achieve this?

Have you tried moving confirmation to another function

function getDeleteHTML(itemId, itemName) {
        var deleteHtml = "<form action='"+ '@Url.Action("Delete", "ManageLocations")'+"/" + itemId +"' method='post'>"
             + "<input type='image' onclick='confirmDelete(" + itemName + ")' value='Delete' class='delete' src='../Images/transparent.gif'>"
             + "</form>";
        return deleteHtml;
    }

function confirmDelete(itemName) {
   return confirm("Are you sure you wish to delete: \n" + itemName + "?");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM