【问题标题】:Telerik MVC Grid in Razor view, GridCommand not populatingRazor 视图中的 Telerik MVC 网格,GridCommand 未填充
【发布时间】:2012-05-21 19:11:43
【问题描述】:

我在 Razor 视图中有一个 Telerik mvc 网格。我正在使用自定义服务器绑定。我的问题是,在分页和排序 GridCommand 对象属性“Page”、“PageSize”和“SortDescriptors”时没有得到正确的值。有趣的是,完全相同的代码适用于 aspx 视图。由于这是一个新视图,我开始使用“Razor”。 我的看法是——

@(Html.Telerik().Grid((IEnumerable<Mitek.MobileImaging.AdminSite.Models.ImagingTransactionModel>)ViewData["DeficientGridView"])
   .Name("DeficientImagesGrid")
   .DataBinding(databinding => databinding.Server()
   .Select("ViewDeficientImages", "SuperAdmin", new { orgId = ViewData["OrgId"], beginDate = ViewData["BeginDate"], endDate = ViewData["EndDate"], searchString = ViewData["SearchString"] }))
   .DataKeys(keys => keys.Add(o => o.TranId))
   .EnableCustomBinding(true) 
   .BindTo((IEnumerable<Mitek.MobileImaging.AdminSite.Models.ImagingTransactionModel>)ViewData["DeficientGridView"])
   .Columns(
        columns => 
        { 
            columns.Template(
                                @<text>
                                   <a href="@Url.Action("DeficientImageDetails", "SuperAdmin", new { id = item.TranId }) ">
                                   <img alt="Deficient Image Details" src= "@Url.Content("~/Content/ImagesUI/detail_icon.gif")"  style="border:0px" /></a>   
                                 </text>
                            ).Title("Actions").Width(75);
            columns.Bound(o => o.TranId).Hidden(true);
            columns.Bound(o => o.user_email).Title("User Email").Width(250);
            columns.Bound(o => o.xml_config_name).Title("Job File").Width(200);
            columns.Bound(o => o.datetime_created).Title("Date Created").Format("{0:MM/dd/yyyy}").Width(200);
            columns.Bound(o => o.short_note).Title("Note").Width(200);
            columns.Bound(o => o.iqa_code).Title("IQA Code").Width(200);
        }).HtmlAttributes(new { style = " font-family:arial; font-size: .9em;  " })
   .Sortable()
   .Pageable(paging => paging.Position(GridPagerPosition.Bottom)
                            .Style(GridPagerStyles.NextPreviousAndNumeric)
                            .Total((int)ViewData["DeficientImagesCount"])
                            .PageSize(25))    
)

控制器的样子

[GridAction(GridName = "DeficientGridView")]
public ActionResult ViewDeficientImages(DeficientImagesViewModel model, GridCommand command, string button)
{
    //Some Code......;            
    GridCommand myCommand = new GridCommand() { PageSize = 25 };
}

命令对象在分页或排序时永远不会有任何 command.Page、command.SortDescriptors 的值。请注意,完全相同的代码适用于 asps 页面。 请帮忙。

谢谢, SDD

【问题讨论】:

    标签: asp.net-mvc-3 c#-4.0 razor telerik-mvc


    【解决方案1】:

    您能否检查它是否与[GridAction(GridName = "DeficientGridView"] 属性和您的网格名称不同.Name("DeficientImagesGrid") 有关?

    【讨论】:

    • 谢谢!...不知道我怎么没看到,这么明显的东西。
    【解决方案2】:

    您必须将 [GridAction(EnableCustomBinding = true, GridName = "DeficientImagesGrid")] 更改为此。我今天有同样的问题,我发现这是有效的。如果您不指定 GridName,那么您将不会获得 GridCommand。

    • 当查询字符串参数为 QueueGrid-size=2&QueueGrid-page=3 时,不填充 gridCommand
    • gridCommand 在查询字符串参数为 size=2&page=3 时填充

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-26
      • 2012-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多