我使用 Devexpress 网格,并且有一个用于更改网格中行数的下拉菜单。但是网格中的行数不会改变。我在网格的 .cshtml 文件中放置了断点,我看到变量 pageSize 具有新值,但网格没有改变。问题可能出在哪里?
这是我的网格定义的一部分:
@{
int initialSize = 10;
int pageSize = ViewBag.PageSize ?? initialSize;
var grid = Html.DevExpress().GridView(
settings =>
{
settings.Name = "gvCompanies";
settings.Width = 960;
settings.CallbackRouteValues = new { "Company", Action = "AllCompanies" };
settings.SettingsPager.Mode = GridViewPagerMode.ShowPager;
settings.SettingsPager.PageSize = pageSize;
settings.ClientSideEvents.BeginCallback = "CompanyBeginCallback";
//... more settings
//column definiton
} );
if ( Model != null )
{
grid.Bind( Model ).GetHtml();
}
else
{
grid.GetHtml();
}
}
下拉更改事件函数:
function ChangeRowsPerPage(s, e)
{
s.Refresh();
}
网格开始回调函数:
function CompanyBeginCallback(s, e) {
e.customArgs["rowsPerPage"] = rowsCount.GetValue();
}
控制器方法:
public ActionResult AllCompanies( int? rowsPerPage )
{
//..some code
ViewBag.PageSize = rowsPerPage;
return PartialView( "CompanyGVPartial", data );
}