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

ClientTemplate not working....

1 Answer 63 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.
Denisas
Top achievements
Rank 1
Denisas asked on 04 Jul 2012, 08:39 AM
I have a grin in a view
@(Html.Telerik().Grid(Model)
    .Name("GridListOfBanners")
    .DataKeys(keys => keys.Add(b => b.BannerID))       
    .DataBinding(dataBinding => dataBinding.Ajax()
        .Select("_SelectBanners", "Banner")                                                                    
        .Update("_UpdateBanner", "Banner")
        .Delete("_DeleteBanner", "Banner"))
            .Columns(columns =>
            {
                columns.Bound(s => s.BannerName).Width(80).Title("Failas");                                                     
                columns.Bound(c => c.BannerWeight).Width(80)
                    .ClientTemplate("<img alt='demo' src='http://demos.telerik.com/aspnet-mvc/Content/Grid/Customers/ALFKI.jpg' />")
                    .Title("Picture");
                columns.Bound(s => s.BannerDisplayName).Width(90).Title("Pavadinimas");
                columns.Bound(s => s.BannerUrl).Width(250).Title("Nuoroda");
                columns.Bound(s => s.BannerEnabled).
                    ClientTemplate("<input type='checkbox' disabled='disabled' name='BannerEnabled' " + "<#=BannerEnabled? checked='checked' : '' #> />")
                        .Width(80).Title("Galiuoja");
                columns.Bound(s => s.BannerFrom).Width(220).Title("Nuo").Format("{0:yyyy-MM-dd}");
                columns.Bound(s => s.BannerTo).Width(220).Title("Iki").Format("{0:yyyy-MM-dd}");
                columns.Bound(s => s.BannerHitsLeft).Width(100).Title("Liko parodym┼│");
                columns.Bound(s => s.BannerClicksLeft).Width(100).Title("Liko paspaudym┼│");
                columns.Command(commands =>
                {
                    commands.Edit().ButtonType(GridButtonType.ImageAndText);
                    commands.Delete().ButtonType(GridButtonType.ImageAndText);
                }).Title("Veiksmas").Width(200);
            })
            .Editable(editing => editing.Mode(GridEditMode.InLine))
            .Pageable()
            .Scrollable(c => c.Height("500px"))
            .Sortable()
)

But it does not render clint template, it shows usual grid, like:
Failas      Picture     Pavadinimas
PavAA.JPG   4       image
PavAA.JPG   5       image2
PavAA1.JPG  5       image2
PavAA1.JPG  5       image2

What is wrong with my code?

1 Answer, 1 is accepted

Sort by
0
Mike
Top achievements
Rank 1
answered on 06 Jul 2012, 07:39 PM
Try adding .Template right before ClientTemplate. I have found that Template runs on first load and ClientTEmplate runs subsequently (like when you are paging).
Tags
Grid
Asked by
Denisas
Top achievements
Rank 1
Answers by
Mike
Top achievements
Rank 1
Share this question
or