4

ASP.NET MVC4 で jqGrid を TreeGrid として使用していますが、問題が 1 つあります。

私のモデル:

OrdersGrid = new JQGrid
                {
                   Columns = new List<JQGridColumn>()
                     {
                        new JQGridColumn
                       {
                         DataField = "MeasureId",
                         // always set PrimaryKey for Add,Edit,Delete operations
                         // if not set, the first column will be assumed as primary key
                         PrimaryKey = true,
                         Visible = false,
                         Sortable = false
                       },
                       new JQGridColumn
                       {
                         DataField = "Name",
                         Width = 100,
                         Sortable = true
                       },
                      new JQGridColumn
                      {
                         DataField = "Symbol",
                         Width = 100
                      },
                      },
                         Width = Unit.Pixel(640),
                         Height = Unit.Percentage(100),
                         TreeGridSettings = new TreeGridSettings
                         {
                           Enabled = true
                         },
                         SortSettings = new SortSettings
                         {
                           AutoSortByPrimaryKey = false,
                           InitialSortColumn = "Name",
                           InitialSortDirection = SortDirection.Asc
                          }
                         };

私のコントローラー:

public JsonResult DataRequested()
  {
     // Get both the grid Model and the data Model
    // The data model in our case is an autogenerated linq2sql database based on Northwind.
       var gridModel = new NavigatorModel();
       ...
       var hierarchyRows = from measure in measures
       select new
       {
           MeasureId = measure.MeasureId,
           Name = measure.Name,
           Symbol = measure.Symbol,
          //ParentID = measure.ParentMeasureId != null ? measure.ParentMeasureId.ToString() : "",
            tree_loaded = true,
            tree_parent = measure.ParentMeasureId,
            tree_level =LoadAllRowsExpanded_GetRowLevel(measure.ParentMeasureId, measures),
            tree_leaf = LoadAllRowsExpanded_IsLeafRow(measure.MeasureId, measures),
            tree_expanded = true
        };

           //var dataModel = new 
          // return the result of the DataBind method, passing the datasource as a parameter
         // jqGrid for ASP.NET MVC automatically takes care of paging, sorting, filtering/searching, etc
           return gridModel.OrdersGrid.DataBind(hierarchyRows.AsQueryable());
    }

上記のように、AutoSortByPrimaryKey を false に設定していることがわかりますが、ページが読み込まれると、グリッドは次のようになります。

jqGridの間違ったソート

列 (名前または記号) の 1 つをクリックして並べ替えると、すべてが正常になります。誤って表示されたメジャーは、その親の下に表示されます。「gridInitialize」の後にソートするイベントでも試しましたが、成功しませんでした。何か案は?

4

0 に答える 0