Datagrid from a list of custom objects

we can not associate a property from the RowExpand event to a datagrid in the template, do we have a best practice to succeed? the list is called up by Invoke custom method

Hi Francesco,

Do you want to have master/detail hierarchy like this article? You can call for example a custom method on RowExpand and pass a parameter from the row data using ${event} argument of the RowExpand to populate the child grid. For example ${event.CustomerID}.

Best Regards,
Vladimir


but the list is not directly connected to the model, I tried to set a property but on the date of the datagrid I can not manage the various fields on the columns

If the child schema is not directly related to the parent schema you can add still DataGrid columns manually however you have to add properties since they will not be available in the intellisense. For example if you want to display hierarchically Customers and Order Details by customer (not directly related):

public IActionResult OrderDetailsByCustomer(string CustomerID)
{
    var context = (NorthwindContext)HttpContext.RequestServices.GetService(typeof(NorthwindContext));

    return Json(context.OrderDetails.Include("Order")
        .Where(i => i.Order.CustomerID == CustomerID)
        .Select(i => new { OrderID = i.OrderID, ProductID = i.ProductID }),
        new JsonSerializerSettings { ContractResolver = new DefaultContractResolver() });
}

thank you so much, now I can easily map a DataGrid

How can I now reload the datagrid after an add or an edit?

If you execute load() method of the grid you will force loadData event to be raised. For example: this.grid0.load()

I can't recover grid2.load () only this.grid0.load(); in a datagrid template, how do I get it?

You want to reload the child grid? You can execute the code that is used to retrieve the data on row expand.