开发者

How do I use a Telerik Grid with a partial page?

开发者 https://www.devze.com 2023-02-13 18:35 出处:网络
I have an ASP.NET MVC project. One of my pages has an input form on top and a partial page below it for results. The partial page uses a Telerik Grid. Everythi开发者_Go百科ng works fine if I dont use

I have an ASP.NET MVC project. One of my pages has an input form on top and a partial page below it for results. The partial page uses a Telerik Grid. Everythi开发者_Go百科ng works fine if I dont use paging. However with paging turned on I can't get the grid to update.

any suggestions?


I am using Telerik Grid with partial views, in the following way:

Action (on "MyController"):

[GridAction]
public ActionResult _GetDataForGrid()
{
  return View(new GridModel
  {
    Data = GetMyViewModelList() // IEnumerable<MyViewModel>
  });
}

(Partial)View:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<MyViewModel>>" %>

<%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .DataKeys(keys => keys.Add(x => x.Id))
        .Columns(columns =>
        {
            columns.Bound(x => x.Id)
            // ...
        })
        .DataBinding(dataBinding => dataBinding.Ajax()
            .Select("_GetDataForGrid", "MyController"))
        .Pageable()
        .Sortable()
        .Filterable()
%>

Hope this helps.


Does your page calling the partial view contain the script telerik.grid.js? There have been cases where it needs to be included in the partial view as well.

Your ScriptRegistrar on the page should include

ASPX Engine

<% Html.Telerik().ScriptRegistrar().DefaultGroup(group => group
   .Add("telerik.common.min.js")
   .Add("telerik.grid.min.js")
   .Add("telerik.calendar.min.js")
   .Add("telerik.datepicker.min.js")
   .Add("telerik.grid.filtering.js")); 
%>

RAZOR Engine

@( Html.Telerik().ScriptRegistrar().DefaultGroup(group => group
       .Add("telerik.common.min.js")
       .Add("telerik.grid.min.js")
       .Add("telerik.calendar.min.js")
       .Add("telerik.datepicker.min.js")
       .Add("telerik.grid.filtering.js")); 
)
0

精彩评论

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