在mvc.grid中过滤网格后停止页面刷新

时间:2017-06-15 06:44:55

标签: asp.net-mvc mvcgrid.net

我正在使用Mvc.Grid(Grid.MVC5),我想停止使用任何过滤器后自动调用的页面刷新。有可能吗?

查看: -

@model IEnumerable< MVC6_Grid_with_filters.Models.SchemeMaster>
@using NonFactors.Mvc.Grid;
@{
    Layout = null;
}

< link href="@Url.Content("~/Content/MvcGrid/mvc-grid.css")" rel="stylesheet" />
< script src="~/Scripts/jquery-2.1.4.min.js">< /script>
< script src="~/Scripts/MvcGrid/mvc-grid.js" type="text/javascript">< /script>

@(Html
.Grid(Model)
.Build(columns =>
{
    columns.Add(c => c.SchemeID).Titled("SchemeID");
    columns.Add(c => c.SchemeName).Titled("SchemeName");
    columns.Add(c => c.city).Titled("City Name");
    columns.Add(o => o.CompanyName).Titled("Company Name");
    columns.Add(c => c.Createddate, "Createddate").Titled("Date");
    columns.Add(c => c.Married).Titled("Married");
})
.Filterable()
.Sortable()
.Pageable()
)
<script>
    $('.mvc-grid').mvcgrid();
</script>

1 个答案:

答案 0 :(得分:1)

您可以在部分视图中使用@Html.AjaxGrid

控制器:

[HttpGet]
public ActionResult Index()
{
    // Only main string query values will be visible here.
    return View();
}

[HttpGet]
public ActionResult IndexGrid()
{
    var list = GetSchemeMasters(); // Your custom list method to get SchemeMasters
    return PartialView("YourPartialView", PeopleRepository.GetPeople());
}

主要观点:

@Html.AjaxGrid(Url.Action("YourPartialAction"))

您的部分观点:

@model IEnumerable< MVC6_Grid_with_filters.Models.SchemeMaster>

@(Html
    .Grid(Model)
    .Build(columns =>
    {
        columns.Add(c => c.SchemeID).Titled("SchemeID");
        columns.Add(c => c.SchemeName).Titled("SchemeName");
        columns.Add(c => c.city).Titled("City Name");
        columns.Add(o => o.CompanyName).Titled("Company Name");
        columns.Add(c => c.Createddate, "Createddate").Titled("Date");
        columns.Add(c => c.Married).Titled("Married");
    })
    .Pageable()
    .Filterable()
    .Sortable()
)