Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
435
Hierarchy Grid with Multiple Layouts using LoadOnDemand feature
posted

Hi,

I have a need to display multiple ColumnLayouts using LoadOnDemand. Currently everything is working as expecting except the Children ColumnLayouts displayed a empty Grid.

GridModel gridModel = this.GetGridModel(ajaxUpdateTarget, 0);
 
                GridUIHelper.ApplyLayout(ref gridModel, vm);
                gridModel.DataSource = resultSet.Result.AsQueryable();
                return gridModel.GetData();

Thank you
Parents Reply Children
  • 17590
    Verified Answer
    Offline posted in reply to Phong Nguyen

    Hello Phong,

    Your requirement could be achieved by handling childGridCreating event. This event is fired before child grid is going to be created and allows the developer to override the child grid creation. In this event a reference to the parent row triggering the event could be retrieved. From the row you could get information about any cell that you would like and will help you uniquely identify your record. Afterwards, this data could be sent to the server(via the dataSource option) and there you could filter your data accordingly. For example:

    //in Grid.cshtml

    $(function () {

    $("#grid-id-test").live("igchildgridcreating", function (evt, ui) {

    var parentRowId = ui.element.parents("tr[data-container='true']").prev().data("id"),

    parentGrid = ui.element.parents("table.ui-iggrid-table").data("igGrid"),

    parentRowData = parentGrid.findRecordByKey(parentRowId);

    //every cell value could be retrieved using the column key

    var productNumber = parentRowData.ProductNumber;

    //afterwards this value could be send to the server via dataSource option

    ui.options.dataSource += "&productNumber=" + productNumber;

    });

    });

    .

    .

    .

    //in HomeController.cs

    public JsonResult GetChildren(string ajaxUpdateTarget, string path, string layout, string productNumber)

            {

               

                if (ajaxUpdateTarget == "History" && productNumber=”AR-5381”)

                {

    //filter your data according to your productNumber and add it to the        response

                  WrappedGridResponse response;

                  response = new WrappedGridResponse(histories, null);

                  return Json(response, JsonRequestBehavior.AllowGet);

                }

                else

                {

     

    //handle it according to you scenario

     

                  

                }

            }

    I believe this approach will help you achieve your requirement. However, we have a known issue logged in our internal system regarding firing of the childGridCreating event. This issue is fixed and currently being tested.

    I have created a support case with an ID of CAS-154476-Q1J6Y4 for you and I will link it to our Development issue so you will get notification when it is released. You could view this case in your account in the Support Activity page.

    Please let me know if you need any further assistance with this matter.