我使用 DevExpress v10.2.3 将 gridview 与 asp.net mvc 4 分组。我可以从数据库中获取数据并显示它们。但我不能改变蚂蚁约束,例如:按列排序。当我点击排序时,我会弹出以下页面。当我每次点击触发脚本时,此页面都会打开。对此有任何想法吗?可能这是一个简单的错误,但我看不到它。
谢谢。
部分视图
@Html.DevExpress().GridView(
settings =>
{
settings.Name = "gvGrouping";
settings.CallbackRouteValues = new { Controller = "Customer", Action = "PartialCustomers" };
settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
settings.Columns.Add("sno");
settings.Columns.Add("Name");
settings.Columns.Add("City");
settings.Columns.Add("Ilce");
settings.Columns.Add("Sokak").GroupIndex = 0;
settings.Settings.ShowGroupPanel = true;
settings.CustomCallback = (sender, e) =>
{
int layoutIndex = Int32.Parse(e.Parameters);
DevExpress.Web.Mvc.MVCxGridView grid = (DevExpress.Web.Mvc.MVCxGridView)sender;
grid.BeginUpdate();
try
{
grid.ClearSort();
switch (layoutIndex)
{
case 0:
grid.GroupBy(grid.Columns["Sokak"]);
break;
case 1:
grid.GroupBy(grid.Columns["Sokak"]);
grid.GroupBy(grid.Columns["City"]);
break;
case 2:
grid.GroupBy(grid.Columns["Name"]);
break;
}
}
finally
{
grid.EndUpdate();
}
grid.ExpandAll();
};
}).Bind(Model).GetHtml()
看法
@model IEnumerable<mvc4devex.Models.Customers>
@{
ViewBag.Title = "Customers";
}
<label for="GroupBy">GroupBy:</label>
<select id="GroupBy" onchange="gvGrouping.PerformCallback(this.value);">
<option value="0">Sokak</option>
<option value="1">Sokak, City</option>
<option value="2">Name</option>
</select>
<input type="button" value="Collapse All Rows" onclick="gvGrouping.CollapseAll();" />
<input type="button" value="Expand All Rows" onclick="gvGrouping.ExpandAll();" />
<br /><br />
@Html.Partial("_PartialCustomers", Model)