开发者

Ajax not working from the initial load of the grid, Templates and ClientTemplates

I have the following code:

@using com.mycompany.myproject.web.ViewModels
@model IEnumerable

@{ Html.Telerik().Grid(Model)
    .Name("Deducciones")
    .Columns(columns => {
        columns.Bound(p => p.IdDeducciones).ClientTemplate("");
        columns.Bound(p => p.FechaInscripc开发者_运维技巧ion).Width(50);
        columns.Bound(p => p.FechaFin).Width(400);
                        })
    .DataBinding(dataBinding => dataBinding
        //Ajax binding
        .Ajax()
        //The action method which will return JSON
        .Select("DeduccionesAjax", "Empleados", new { id = ViewBag.Id })
    )
    .Pageable(pager => pager.PageSize(2))
    .Sortable()
    .Render(); }

The grid renders fine but only uses the client template when I go to page 2 for instance. On the initial load it doesn't use it. As a workaround I added .Template(@<text><a href='#'>@item.IdDeducciones</a></text>); after the ClientTemplate and now it works on both the initial load and afterwards. However this seems strange as none of the examples or docs I've seen specify both a Template and a ClientTemplate.

Is there something I'm missing that's making the first load not come from Ajax or something similar?

Thanks in advance.


As I replied in the forum thread which you opened in the Telerik forums this is expected and documented. Client templates apply only when doing client binding (such as ajax). Templates are applied during server binding such as :

Html.Telerik().Grid(Model)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜