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

MVC grid data initially shows, then vanishes

1 Answer 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 06 Mar 2014, 07:34 PM
Kendo.UI 2013.3.1324

I am cutting/pasting sample code from MVC grid control for local data.  My IEnumerable list of data is populated into SearchResults.  When I look at the HTML source, I see all the row and column data in the table, and repeated again in the kendoGrid() method as JSON.  Not sure why it is repeated again here.  What actually renders though, is that I see all the data in the grid flash for a millisecond on page load, but then it shows "No items to display" with empty grid.  Obviously when it hits the kendoGrid() method, something goes wrong.  If I add Deferred(true), then the grid is populated, but paging does an undesirable postback.  So, why is the code populate both the HTML table, and the JSON passed to kendoGrid() method?

‚Äč @(Html.Kendo().Grid(Model.SearchResults)
.Name("GridResults")
.Columns(columns =>
{
columns.Template(p => @Html.ActionLink("Edit", "Edit", new { Id = p.RecipeId }));
columns.Bound(p => p.ProductType).Title("Type");
columns.Bound(p => p.DisplayRecipeId).Title("Recipe ID").Width(130);
columns.Bound(p => p.RecipeName).Title("Recipe Name").Width(130);
columns.Bound(p => p.Status).Width(130);
columns.Bound(p => p.CreateDate).Title("Create Date");
columns.Bound(p => p.RevisedDate).Title("Revised Date");
})
.Pageable()
.Sortable()
.Scrollable(scr => scr.Height(350))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(15)
.ServerOperation(false)
)
)

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 10 Mar 2014, 01:54 PM
Hello Greg,

Could you verify that the kendo.aspnetmvc JavaScript file is included? The serialized data will not be bound if the file is missing.
The data is rendered in the table because it is bound on the server:
Html.Kendo().Grid(Model.SearchResults)
It is also serialized in the initialization script because an Ajax dataSource is used:
.DataSource(dataSource => dataSource
    .Ajax()

Also, note that when using Ajax binding you should use a ClientTemplate instead of a Template. For an example on how to render a link with the ClientTemplate and set a query string parameter to a field in the model, please check this topic.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Greg
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or