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

Problems with "template columns" in a "grid" with ajax paging

2 Answers 123 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Wilfredo
Top achievements
Rank 1
Wilfredo asked on 30 Mar 2011, 12:19 AM
Hi everybody,

I have problems working with "templated columns" and "ajax paging" in a Grid (ASP.NET MVC). When you click on the paging buttons, the template columns don't show the links again.

I'm attaching an example,

Thanks in advance,

Wilfredo Nacho



2 Answers, 1 is accepted

Sort by
0
Dave Crack
Top achievements
Rank 1
answered on 06 Apr 2011, 12:04 PM
Same Problem here:

http://demos.telerik.com/aspnet-mvc/razor/grid/templatesserverside

with Razor and AJAX Binding doesnt work, the Template (Server) Column is empty either emtpy or if also bound only shows bounded value, by the way is there any best practice of binding LazyLoaded Properties via EF4 / Navigation (1:n) an keep filter alive?:

@(
 Html.Telerik().Grid(Model)
        .Name("Grid")
        .EnableCustomBinding(true)
        .Columns(columns =>
        {
            columns.Bound(o => o.TaskID);
            columns.Template(
                @<text>
                    Test @item.TaskID
                </text>
            ).Title("Test Template");
 
        })
        .DataBinding(dataBinding => dataBinding.Ajax().Select("_Paging", "Task"))
        .Pageable(paging => paging.Total(ViewBag.totalCount).PageTo(1).PageSize(20).Style(pagerStyles))
        .Scrollable((scroll) =>
        {
            scroll.Height(500);
        })
        .Sortable()
        .Filterable()
)

0
jpchenot
Top achievements
Rank 2
answered on 22 Jun 2011, 03:57 PM
I believe that your issue lies in the fact that you are mixing server and client binding.

Basically, the Template property is a server-side property. For AJAX you must use the ClientTemplate property. But if you do so, you cannot bind the Model to the grid because it automatically assumes that it is going to be server bound. 

You must change the first line to:
Html.Telerik().Grid<T>()
T being the Type of your model.
The grid will automatically make an AJAX call to load the data.

I hope this helps.
Tags
General Discussions
Asked by
Wilfredo
Top achievements
Rank 1
Answers by
Dave Crack
Top achievements
Rank 1
jpchenot
Top achievements
Rank 2
Share this question
or