-1

私は JqGrid を初めて使用するので、このリクエストを手伝ってください。

リンクに示すように、3 レベルの階層 JqGrid 設定があります。まったく同じではありませんが、非常に似ています。私の要件は、が展開されCustomerGridたときに の主キーも渡されるようにするOrderGridことです。

または要するに、私はしたいです

    public void SetUpThreeLevelGrids(ThreeLevelHierarchyJqGridModel model)
    {
        var customersGrid = model.CustomersGrid;

        // code here

        int cId;
        //cId = <CustomerId from the CustomerGrid>; //*****How to get this******
        ordersGrid.DataUrl = Url.Action("ThreeLevel_OrdersDataRequested", new { customerId =  cId });

        // code here
    }

ThreeLevel_OrderDetailsDataRequestedメソッドに渡されたその変数を使用したいと思います。

public JsonResult ThreeLevel_OrderDetailsDataRequested(int customerId, string parentRowID)
{
    // code here
}
4

1 に答える 1

0

コントローラーに CustomerId という名前の静的変数を作成しました。これが何かを壊す可能性があるかどうかはわかりません。私はそれを機能させたかっただけです。

public static int customerId = 0;

2 番目のグリッドの Action メソッドでは、CustomerId 値を割り当てました。

public JsonResult ThreeLevel_OrdersDataRequested(string parentRowID)
{
    var northWindModel = new NorthwindDataContext();
    var model = new ThreeLevelHierarchyJqGridModel();
    customerId = int.Parse(parentRowID);
    SetUpThreeLevelGrids(model);

    //code
}

第 3 レベルのグリッドでグローバル静的変数にアクセスしました。

public JsonResult ThreeLevel_OrderDetailsDataRequested(string parentRowID)
{    
    //Code
    var orderDetails = from o in myDbModel.MyCustomerOrderDetails
         where o.OrderID == Convert.ToInt32(parentRowID)
         and o.CustomerId == customerId //static global variable
         select o;

    //Code
}

第 1 レベルのテーブルで選択された主キーを第 3 レベルのグリッドで取得するためのより良い提案がある場合は、お知らせください。

于 2014-10-10T16:01:44.320 に答える