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
Hello Phong,
Thank you for posting in our community.
In order to address the root cause of your issue and provide you with better and more accurate support I will need an isolated working sample where the issue is reproducible. This will help me debug on my side and investigate further and find what is causing this behavior.
Additionally, a sample project illustrating Load on Demand functionality in igHierarchicalGrid could be found at the following link:
http://igniteui.com/hierarchical-grid/load-on-demand
Please have a look at this sample and if you still have any questions or concerns afterwards please fell free to get back to me with your isolated sample.
Looking forward to hearing from you.
Hello Vasya,
Thank you for getting back to me.
Yes, I did follow the Load On Demand Example.Here is what I am trying to do. Our database has over Million records. We want to take the advantage of SQL Server paging and Load On Demand, so we get the Total Count, then the first 10 records to display. Everything is working so far. However, I have a requirement to display data in Hierarchy, a Parent record would have two or more GridColumnLayoutModels.I attached the code sample. Please help
This is exactly what I need for my requirement. I have another question based on this same structure/Grid setup that I will need soon. How can I get the Row of Data (Selected Data Object) and post back to the server when user click on "+" icon?
Thank you very much
I am glad that you find my suggestion helpful.
I just want to let you know that in order to ensure all your issues are addressed correctly we handle single issue per forum thread. This helps our customers find what they are looking for easily. I can suggest you next time when you have a question which is not directly related to the initially discussed to start a new thread in our forum.
Regarding your additional question I will need some more information. Could you please be more specific for what you are trying to achieve when you click the expanding button? Any details are going to be highly appreciated and will help me find a way for achieving your requirement.
Yes, I will start a new thread next time. The reason I appended to this thread because the feature I need is related to this solution pattern.
Anyway, based on the example I provided. I am looking for a way to get the Selected Row so I can get the data to Query the data for Children grids.
Currently, I have to do:
1. Get the Primary Key of the Parent Row
2. Query the Parent data based on the Primary Key
3. Query the Child data based on the Parent data
You can see there is a lot of step if I have another nested Grid in a Child grid. So I am looking for the way get the Selected Row of the expanding row.
This is another important feature that I need to complete the requirement.
What I can suggest for achieving your requirement is using GetChildren method. This method parameters will give you enough information to determine which is the current ProductID, respectively which parent row invoked the GetChilden method. Layout parameter contains information about the current layout. Based on these two parameters you could filter your data in order to retrieve only the rows needed for the corresponding child. For example if I am trying to expand first row, Adjustable Race 0, GetChild method will be called with ajaxUpdateTarger="Histories", path: ProductID: 0,layout="Histroies". You could check which layout triggered the event and filter data accordingly and add it to the WrappedGridresponse.
public JsonResult GetChildren(string ajaxUpdateTarget, string path, string layout) { if (ajaxUpdateTarget == "History") { //filter your data according to the path and layout and add filtered data to the response WrappedGridResponse response; response = new WrappedGridResponse(histories, null); return Json(response, JsonRequestBehavior.AllowGet); } else { //filter your data according to the path and layout and add filtered data to the response gridModel.DataSource = something.AsQueryable(); WrappedGridResponse response; response = new WrappedGridResponse(something, null); return Json(response, JsonRequestBehavior.AllowGet); } }
public JsonResult GetChildren(string ajaxUpdateTarget, string path, string layout)
{
if (ajaxUpdateTarget == "History")
//filter your data according to the path and layout and add filtered data to the response
WrappedGridResponse response;
response = new WrappedGridResponse(histories, null);
return Json(response, JsonRequestBehavior.AllowGet);
}
else
gridModel.DataSource = something.AsQueryable();
response = new WrappedGridResponse(something, null);
I hope you find this information helpful.
Please let me know if you need any further assistance with this matter.
Hi Vasya,
The problem is ProductID information is not enough for me to get the Related Information of the Children. This is what I am trying to do:
1. From the expanding row, get the ProductId, ProductName, and other information. I don't want to go to the database to get the Product based on ProductId. This is not efficient because I have many nested Grids per Product.
2. Filter the Children data with (ProductId, ProductName, and other information)
3. Bind the result to the response
Please help. Thank you
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 } }
//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
//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.
Thank you.
I am need have to solution ASAP.
Thanks again for looking into it.
I am currently looking into this matter for you. I will get back to you soon with more information or questions for you.