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.
This is an important post. I think some of the developers should weigh in on this one. It's extremely limiting of the WHDG to constantly select the entire database.
The reason the grid hits every row's children is that it has to know whether the row has any children and whether the expansion indicator needs to be rendered.
Just like Dave suggested I can point you to using the manual load on demand, and the IsEmptyParent can be played with to instruct every row if it is supposed to have child rows. Although I'd imsagine you on your own will have to touch the db to figure out that.
If the property is left untouched the indicator will appear on every row in the manual mode, then clicking it will do nothing for childless rows.
The only event which seems to expose the isemptyparent property is the rowexpanded event. How would I use this to render the expansion indicator on the initialize row event?
Although I have been able to set up the manual load on demand, I don't understand how I could ever create logic to find children of a row manually (which would mean that I have some piece of info about the parent) and still be able to set the expansion indicator at that point in time. Is the data of the row available to me before the rendering of the expansion indicator?
Well I guess that is the trick here.. Just like the grid does in the automatic mode you would have to ping the child table to see if there are any related child rows for each parent row.
Setting the property oin the parent's InitializeRow should be well in advance of rendering of the indicator.
Thanks for the reply. How can I set the isparentempty property in the initialize row event?
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?
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 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.
hi
i tried above code but no expansion indicator in the webHierarchicalDataGrid, i am also trying same thing manual load on demand.
if there is any other options...
thanks
Srikanth
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>