Hi,
I've been having a really hard time with the WHDG performance. I have a parent and child band which are being fed by two sqldatasources into one WebHierarchicalDataSource. The query in the child's datasource is simply "select * from [jobparts]." Every time I hit the expand button, that sqldatasource runs a "select * from [jobparts]" which returns thousands of records and then picks out the one or two rows it needs to display in the child band. (You can see that by watching the sqldatasource_selected event and checking the affectedrows property of e)
So I tried using manual load on demand to load the data in code in the rowisland_populating event when the expand button was hit. Same problem, since the sqldatasource of the child is still connected to my webhierarchicaldatasource, it does the whole select process and THEN it populates the WHDG through my code. So then I changed the query in the child's sqldatasource to something that doesn't return any records but that makes me lose the expand button on the parent band all together so I can never get into the rowisland_populating event at all.
Is there a way to set this up so that the child datasources only select what they need from the database? I was thinking of setting up some crazy custom paging scheme for the chld band queries, but I don't have enough Tylenol in the office to start thinking about that.
Edit: I just figured out a possible way by using the WebHierarchicalDataGrid1_RowIslandDataBinding event and changing the selectcommand of the sqldatasource of the child there. I have to make sure not to change it when the parent grid loads so that the expand buttons will be created. I'm not sure how to get the parent rows datakey in that event though.
Thanks, Ed
Hi Ed,
If you want to implement manual load on demand, you can tell a row that is a parent even if the datasource has no child grids for it yet by setting IsEmptyParent off of the row to true. Then in the rowIsland_Populating event, you can add your data that you want similar to how it is described in this help document.
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2009.2/CLR3.5/html%5CWebHierarchicalDataGrid_Manual_Load_On_Demand.html
This DataTree sample shows how to set up IsEmptyParent
http://samples.infragistics.com/2009.2/WebFeatureBrowser/contents.aspx?showCode=true&t=WebDataTree/WebDataTreeManLoadOnDemand.aspx~srcview.aspx?path=~srcview.aspx?path=WebDataTree/WebDataTreeManLoadOnDemand.src
Let us know if you need more help,
regards,David Young
I just looked into the IsEmptyParent, but I'm not sure what you're suggesting to do with it. Which method do you suggest for getting just the records I need? I really like the idea of altering the sql selectcommand in the rowislanddatabinding event. I need to get my key field from the parent row which I can't seem to get. I tried using e.RowIsland.ParentRow but it's always nothing in the rowislanddatabinding event.
Thanks for the reply. I will get to testing this in depth over the weekend.
Ed
The example in the help file for manually populating the island in the RowIslandsPopulating event looks like the following:
// Create Container Grid ContainerGrid childGrid = new ContainerGrid(); e.Row.RowIslands.Add(childGrid); // Bind Grid childGrid.DataSource = products; childGrid.DataBind();
// Create Container Grid
new
// Bind Grid
Instead of creating a new ContainerGrid, can I somehow use an
existing band and bind to that instead in the
RowIslandsPopulating event?
<Bands> <ig:Band AutoGenerateColumns="false" Key="TXN" > <Columns> <ig:BoundDataField DataFieldName="TXN_CD" Key="TXN_CD"
Header-Text="Transaction Code" /> <ig:BoundDataField DataFieldName="ISSUED_DT" Key="ISSUED_DT"
Header-Text="Issue Date"/> </Columns> </ig:Band> </Bands>
I found that you can do something like this
ContainerGrid childGrid = new ContainerGrid(); childGrid.Band = WebHierarchicalDataGrid1.Bands[0]; e.Row.RowIslands.Add(childGrid);
if you have an existing band declared in markup, athough it gives me a casting error if I try and expand multiple bands at a time.
I've been playing around with this, and had one large problem - something is missing when you create a new containerGrid - when any cells in the new rows are updated there is a "not implemented" error on the client side (the update may or may not go through). Something appears to be not quite linked between the containerGrid bound server side and the requirements of the grid client side to save (despite it working fine when everything was bound using only the default "getAll" queries)
Any ideas?
I also notice that the grid internally still calls the default "getall" query in the hierarchical data markup on the page, sometime MULTIPLE times before it then calls the RowIslandsPopulating event server side. While I commented out the sever side ftn so it didn't return any rows, it is a concern - no wonder it runs slowly.
I am having problems as well with perfomance and editing. I found that when I am using the LoadOnDemand whith no DataSources in markup and creating everything inside RowIslandsPopulating this does solve the multiple "getAll" queries.
My problem comes in when I try and do an update inside a child row, are you doing updates in a child or parent row?
I get an "Object reference not set to an instance of an object" ......
Any thoughts on this?