2012-07-03 77 views
0

我使用的DevExpress v10.2.3分組GridView控件與asp.net的MVC 4.我可以從數據庫中獲取DATAS,並告訴他們。但我不能改變螞蟻的約束,例如:按列排序。當我點擊排序我獲得以下彈出page.This頁面打開時我每按一下火腳本。對此有何想法?可能這是一個容易的錯誤,但我無法看到它。的DevExpress GridView的gruping?

謝謝。

enter image description here

partialView

@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> 
&nbsp; 
<input type="button" value="Collapse All Rows" onclick="gvGrouping.CollapseAll();" /> 
&nbsp; 
<input type="button" value="Expand All Rows" onclick="gvGrouping.ExpandAll();" /> 
<br /><br /> 
@Html.Partial("_PartialCustomers", Model) 
+1

settings.CallbackRouteValues = new {Controller =「Customer」,Action =「PartialCustomers」}; PartialCustomers是否返回PartialView? (它應該非常簡單,只是是你用你的指標相同梅索德) –

+0

我解決它感謝關注。我用局部視角。我改變了它。非常感謝。 –

+0

這是愚蠢的錯誤:) –

回答

2

這個問題對以下任一原因造成的:

  • GridView控件訊號分配延長在單獨的PartialView中定義的sion包含附加標籤;

  • 內CallbackRouteValues.Action屬性正確實現指定的動作(應該返回與GridView中PartialView)。

+0

非常感謝你。 –