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

[Solved] Grid ClientTemplate Issue

0 Answers 21 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.
Anthony
Top achievements
Rank 1
Anthony asked on 09 Apr 2012, 04:19 PM
Hi I am trying to have a custom edit client function inside of the MVC Grid using the ClientTemplate. 

Below is my grid:

@(Html.Telerik().Grid(Model)
        .Name("TranslationGrid")       
        .DataKeys(keys => keys.Add(r => r.ResourceId))       
        .Columns(columns =>
        {              
            columns.Bound(r => r.DefaultContent).Title("Default Language Content").Width(200);
            columns.Bound(r => r.SelectedLanguageContent).Title("Your Language Content");
            columns.Bound(r => r.Description).Title("Description");               
            columns.Bound(r => r.ResourceId).ClientTemplate("<a href=\"#\" class=\"t-button t-grid-edit\" onclick=\"editResource('<#= ResourceId #>', '<#= SelectedCultureId#>', '<#= DefaultContent#>', '<#= SelectedLanguageContent#>')\">Edit</a>").Width(100).Title("");
        })
        .ClientEvents(events =>
            events.OnDataBinding("onDataBinding"))
        .DataBinding(dataBinding => dataBinding.Ajax()
            .Select("LanguageTranslations", "Resource")
                    .Update("LanguageTranslations", "Resource")
            )                       
        .EnableCustomBinding(true)          
        .Pageable(settings => settings.Total((int)ViewData["itemtotal"]))           
)


The issue I have is that <#= SelectedLanguageContent#> can sometimes result into an HTML code block which causes the grid to render incorrectly along with javascript errors. 

I really want to avoid encoding the string from the controller or model. Can anyone advise on how I should go about this?

Thanks

Anthony 

Tags
Grid
Asked by
Anthony
Top achievements
Rank 1
Share this question
or