I am using html.Encode when saving the data in the db. So in the db I have <> but when I show the data in the grid to the users I want them to see <>. How can I accomplish decoding the string?
function loadActivity2Grid() {
intCompanyValue = $('#hdnCompanyID').val();
if (intCompanyValue != "0" && blnActivityLoaded == false) {
var ds = new kendo.data.DataSource({
transport: {
read: {
url: "WebService.asmx/loadActivity",
dataType: "json",
contentType: "application/json; charset=utf-8",
type: "GET",
data: { intCompanyID: intCompanyValue }
}
},
pageSize: 10,
schema: {
//data: function (data) {
// return data.d;
//},
data: "d",
total: "d.length",
model: {
fields: {
intNoteID: { type: "number" },
ActType: { type: "string" },
Employee_Name: { type: "string" },
appt_date: { type: "date" },
activity_completed_date: { type: "date" },
OutcomeNotes: { type: "string" },
ContactName: { type: "string" }
}
}
}
, sort: ({ field: "appt_date", dir: "desc" })
});
$("#grdActivity2").kendoGrid({
dataSource: ds,
width: 870,
filterable: true,
sortable: {
mode: "multiple"
},
pageable: {
refresh: true,
pageSizes: true,
previousNext: true
},
scrollable: false,
columns: [
{
template: '<input type="button" class="btn_small" value="View" onclick="viewActivity(\'#=intNoteID#\');" />', width: 50,
width: 50
},
{
field: "ActType",
title: "Type",
width: 75
},
{
field: "Employee_Name",
title: "Assigned To",
width: 125
},
{
field: "appt_date",
title: "Scheduled<br>Date",
format: "{0:MM/dd/yyyy}",
width: 75
},
{
field: "activity_completed_date",
title: "Date<br>Completed",
format: "{0:MM/dd/yyyy}",
width: 75
},
{
field: "OutcomeNotes",
title: "Outcome/Notes",
width: 345
},
{
field: "ContactName",
title: "Contact",
width: 125
}
]
});
}
}
8 Answers, 1 is accepted
Hello Todd,
You can use the encoded property of the column and set it to true, so the HTML string is displayed as is. Here is an example:
Regards,Kiril Nikolov
Telerik
Hi,
How do we handle this for dynamically bound grids? where columns are generated dynamically.
Please open a separate support request with the code of your generated columns and we will be happy to take a look and provide with a possible solution.
Thanks for the understanding.
Regards,
Kiril Nikolov
Telerik by Progress
http://dojo.telerik.com/IfIti
I can't see any differences with the property set to true and false, I see in both the situations displayed the string "<b>Jane Doe</b>"
How can I see "Jane Doe" in bold?
Putting markup in data will not affect the presentation. You need to do it in the template:
http://dojo.telerik.com/IfIti/500
Regards,
Kiril Nikolov
Telerik by Progress
Ok in this manner it works, my problem is that the data I have to display is stored on database in html.
It contains text and html for example
"Warn: look data present in historical values of <a href='url'>Dow Jones</a>
In this case I can't create a template because datas contains different formats
Thank you
Claudio
Then you should not be using template - either display the HTML from the database or use a template, both are not supported at the same time.
Regards,
Kiril Nikolov
Telerik by Progress