Advice needed for LLBLGen, GridEx and Hierachy

Posts   
 
    
Posts: 11
Joined: 29-Oct-2008
# Posted on: 30-Oct-2008 00:01:25   

Hi Support,

I want to use GridEx (v3) with LLBLGen datasource (v2.6) + VB VS2005. The data is contained in two tables. Order Header and Order detail linked by the OrderId. I have created a web page with an LLBG DataSource pointing to the Order Header + Order Detail Entity Collection. Retrieve Hierarchical Structure loads the Root and child table into GridEx OK. Viewing, Editing and Adding to the Root table all work OK.

I cannot see any of the data for the child table. I have added a Sub to handle GridEX1.RetrievingChildSource event which fills the Child table OK.

My question is should the GridEx + LLBGen retrieve, insert and update the Child table without any code or have I left something out? If I need to use code to do the retrieve, insert and update is there a preferred way to do this?

Thanx Colin...smile

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 30-Oct-2008 06:07:13   

ColinPBriggs wrote:

Retrieve Hierarchical Structure loads the Root and child table into GridEx OK. Viewing, Editing and Adding to the Root table all work OK.

I cannot see any of the data for the child table. I have added a Sub to handle GridEX1.RetrievingChildSource event which fills the Child table OK.

Do you mean that the hierarchical retrieve it's ok but something else (insert, update, delete) isn't?

Have you set the 'hierarchical' property in the grid to true?

David Elizondo | LLBLGen Support Team
Posts: 11
Joined: 29-Oct-2008
# Posted on: 30-Oct-2008 23:07:28   

Hi Daelmo,

Gridex has a function in design mode that will allow you to retrieve the table structure from the datasource, this is used to generate the tables and columns in the Grid. This works OK, I can see all the tables and columns in design mode.

The 'hierarchical' property is set to true.

My problem is at run time. I see the + next to the header record in the grid indicating there is a child record. If I expand it I get no child records.

If I add the code to retrieve the child records it works. I guess my problem is the poor documentation on GridEX regarding using a Hierachy. Should it retrieve the child records without any code or did I miss something?

I have used Gridex with an SQL data adapter and a hierarchy in VS2003. Because the databinding in Net 1.x wasn't smart enough to do updates, deletes etc I had to code it all. I was hoping that LLBLGen with Gridex in Net 2.x it would do all this out of the box. If it does could you please point me at some documentation on how to set it up.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 31-Oct-2008 06:35:16   

Ohh I see. I think the thing is that you are using Adapter TemplateSet, so no lazy-loading is happening here. This is what is happeging:

  1. The page is loaded.
  2. The Grid ask for the data.
  3. The associated LLBLGenProDataSource2 fetch the data (if livePersistance is false, PerformSelect event handler is called).
  4. You click the "+" link to show the childs.
  5. The Grid ask for the child collection. That's ok. The thing is that the child collection is empty. In Adapter scenario, no automatic fetch on demand (lazy-loading) is performed.

So you have two options:

  1. Prefetch the child collection. This way, the collection wont be empty at step 5. Note that this will prefetch the childs for every fetched entity.
void Page_Load()
{
     if (!IsPostBack)
     {
          myLLBLGenProDataSource.PrefetchPathToUse = myChildPath;
     }
}
  1. Do what you are doing right now: catch the "+" link click and perform the fetch of the child collection for the involved entity.
David Elizondo | LLBLGen Support Team