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
2700
Displaying Hierachial data with Load on Demand
posted

Hi,

I am trying to use the WebHierarchicalDatagrid to display an 'n' level data structure using load on demand.  My data is a stock control type system with a root node of 'Location' in which there are 1 or more instances of a 'Component'.  Each 'Component' may have child components which in turn may themselves have child components - to any level really.

Location
     Component
          Component
                Component
                   ...

I already have a LOCATION and COMPONENT object returned from my Data Access Layer.  I have created the grid with AutoGenerateBands and AutoGenerateColumns DISABLED as I do not want to display all of the data in the LOCATION or COMPONENT objects

I have created 2 bands so far to test the structure.  Band 0 will display the location and as I only want to display its name I have created a bound column and set its DataFieldName to 'Name' which is the property of the LOCATION object which returns the name.  I have also set the DataKeyFields property of the band to ID as this is the name of the property of LOCATION which returns the database ID.

My second (child) band has 2 columns, Part Number and Description.  These are also bound to the appropriate members of the LOCATION object.

My Page_load event populates the root band by adding a single LOCATION object to a list and using this as the DataSource - for some reason the Grid then crashes with

Infragistics.Web.UI.GridControls.WebHierarchicalDataGrid.DataBind() +1082
 An item with the same key already exists

I have only added 1 item to the grid.

Help please as I'm not even sure that I am approaching this the right way.

 

 

 

 

 

Parents
  • 2700
    Offline posted

    I have also just tried setting the grid to auto-generate bands and columns - works for the first level but when I try to add expanded items using the following code:-

     

     

     

     

     

     

     

    ComponentList listComponents = new ComponentList();
    listComponents.Populate(
    null ,-1 ,locationID, "", "", true);

     

     

    // Create Container Grid
    ContainerGrid childGrid = new ContainerGrid();
    e.Row.RowIslands.Add(childGrid);

     

     

    // Bind Grid
    childGrid.DataKeyFields = "ID";
    childGrid.Level = e.Row.Level + 1;
    childGrid.DataSource = listComponents;
    childGrid.DataBind();

    I get an exception thrown of :- The given key was not found in the dictionary

    I assume it is referring to the DataKeyFields set to 'ID@ which I know is the property to return the database ID of the component and does exist as a property of the Component object.

     

Reply Children
No Data