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

[Solved] Column Encoding with Ajax Binding

1 Answer 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Galina
Top achievements
Rank 1
Galina asked on 09 Jun 2010, 11:50 AM
Dear customer support,

According to the Grid documentation the contents of every column is html encoded by default which should be the same if .Encode(true) is used.

I am using Ajax binding and the column contents is never encoded.
When I switch to Server binding the column contents is encoded.

Telerik.Web.Mvc.dll is version 2010.1.309 for MVC 2.

Is html encoding supported by Server binding only or there is something I can do to get it working for Ajax as well?

Thank you very much!

Regards,
Galina

1 Answer, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 09 Jun 2010, 12:54 PM
Hello Galina,

Yes, for the time being encoding is supported only in server binding mode. Until we implement that in ajax binding you can use a workaround via client templates:

<script type="text/javascript">

function encode(value) {
    return value.replace(/&/g, '&amp;')
                .replace(/</g, '&lt;')
                .replace(/>/g, '&gt;');
}

</script>

<%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(o => o.ContactName).Width(200).ClientTemplate("<#= encode(ContactName)#>");
        })
$%>

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Galina
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or