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

How to render "&" in Grid column

2 Answers 301 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Philip
Top achievements
Rank 1
Philip asked on 02 Dec 2011, 08:13 PM
In my data source, one of the columns is a string data type and contains the "&" in the text. When the grid renders, it's translating those "&"s to &

How can I prevent this from happening? I'm binding to a local data source and I have a schema defined:

dataSource: {
    data:
    [
        @foreach (var report in Model.Reports)
        {
            <text>{Id: "@report.Id", ReportId: "@report.ReportId", ReportSample: "@report.ReportSample", ReportLegend: "@report.ReportLegend", ReportFaq: "@report.ReportFaq", ReportName: "@report.ReportName"}, </text>
        }
    ],
    schema: {
        model: {
            fields: {
                Id: { type: "number" },
                ReportId: { type: "string" },
                ReportSample: { type: "string" },
                ReportLegend: { type: "string" },
                ReportFaq: { type: "string" },
                ReportName: { type: "string" }
            }
        }
    }
}

Is there possibly a way in the column definition to tell it to render those "&"s as actual "&"s?

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 05 Dec 2011, 09:00 AM
Hi Philip,

In order not to encode the data shown in particular grid column, you should set encoded options to the column to false:

$("#grid").kendoGrid({
    dataSource: {
        data: dataSource                         
    },
    columns: [ {
            field: "foo",
            width: 90,
            encoded:false
        }]
});

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Philip
Top achievements
Rank 1
answered on 05 Dec 2011, 06:22 PM
Thanks Rosen,

I didn't see that option in the demos on the Configuration tab, but it works great!
Tags
Grid
Asked by
Philip
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Philip
Top achievements
Rank 1
Share this question
or