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
655
Hierarchical Grid: NullReferenceException thrown in GridModel.RenderHierarchicalQueryableRecursive
posted

Hello,

I'm following the example to show my data in a grid.
http://samples.infragistics.com/jquery/hierarchical-grid/hierarchical-grid-load-on-demand

My data has 2 levels. Each row in the 1st level table is a Dictionary<string, object>, row["child"] is data for the child table of the row.

I succeeded to show the 1st level table. However, when I tried to show the 2nd level tables, a NullReferenceException was thrown:

 

And I have no idea what's going on.

Here are a piece of my code:

-----------------------------------------------------------------------------

GridModel grid = new GridModel();
grid.PrimaryKey = "UserId";

grid.AutoGenerateColumns = false;
grid.LoadOnDemand = false;


grid.Columns = new List<GridColumn>();
grid.Columns.Add(new GridColumn("UserId Text", "UserId", "", ""));
grid.Columns.Add(new GridColumn("User Name Text", "Name", "", ""));

grid.AutoGenerateLayouts = false;

GridColumnLayoutModel layout = new GridColumnLayoutModel();
layout.Key = "child";
layout.PrimaryKey = "RowId";
layout.ForeignKey = "UserId";
layout.LoadOnDemand = false;
           
layout.AutoGenerateColumns = false;
layout.Columns = new List<GridColumn>();
layout.Columns.Add(new GridColumn("Height Text", "Height", "", ""));

///////////////// if this line is commented, no exception is thrown
grid.ColumnLayouts.Add(layout);  

grid.DataSource = new object[]
    {
        new Dictionary<string, object>()
        {
            {"UserId", "10001"},
            {"Name", "Jack"},
            {"child",
                        new object[]    // child table
                        {
                            new Dictionary<string, object>()
                            {
                                  {"RowId", "99999"},
                                  {"UserId", "10001"},
                                  {"Height", "178"},
                                  {"Weight", "99"},
                            }
                       }.AsQueryable()
            }
        }
    }.AsQueryable();

return grid;

-----------------------------------------------------------------------------

What's wrong with the code?

Any help is appreciated.

Best regards,

Zach_Shine

Parents Reply Children
No Data