This is a migrated thread and some comments may be shown as answers.

html decode issue with strings in a grid cell

8 Answers 2105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Todd
Top achievements
Rank 1
Todd asked on 03 Apr 2015, 07:43 PM

I am using html.Encode when saving the data in the db.  So in the db I have &lt;&gt; 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

Sort by
0
Kiril Nikolov
Telerik team
answered on 07 Apr 2015, 07:56 AM

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:

http://dojo.telerik.com/IfIti

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Diptesh
Top achievements
Rank 1
answered on 02 Aug 2016, 02:01 PM

Hi,

How do we handle this for dynamically bound grids? where columns are generated dynamically.

 

0
Kiril Nikolov
Telerik team
answered on 03 Aug 2016, 05:30 AM
Hi,

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
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Stefano
Top achievements
Rank 1
answered on 02 Mar 2017, 10:38 AM

 

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?

0
Kiril Nikolov
Telerik team
answered on 02 Mar 2017, 02:13 PM
Hello,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Stefano
Top achievements
Rank 1
answered on 03 Mar 2017, 08:35 AM

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

 

0
Kiril Nikolov
Telerik team
answered on 06 Mar 2017, 08:25 AM
Hi,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Stefano
Top achievements
Rank 1
answered on 09 Mar 2017, 09:56 AM
Thank you it works!!
Tags
Grid
Asked by
Todd
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Diptesh
Top achievements
Rank 1
Stefano
Top achievements
Rank 1
Share this question
or