I have a WebHierarchicalDataSource created and set relations visually on aspx page.
I need to filter the undelying dat ato display in the Ultrawebtree. I can change the SqlDataSource.SelectCommand for both data sources (just two levels in the tree) and it filters fine. The only problem is that each parent node appears as many times as there is a max och child nodes. My guess is that the Relationship in WebHierarchicalDataSource needs to be reset.
What is the proper syntax to do that? Or is it a different problem?
Here is the snip of the code I am using:
SqlDataSource2.SelectCommand =
SqlDataSource1.SelectCommand = "SELECT tClients.ClientID, tClients.ClientName FROM ...
WebHierarchicalDataSource1.DataBind()
UltraWebTree1.DataBind()
UltraWebTree1.ExpandAll()
Thanks
I am trying to do the same thing that the original poster did, but getting different results.
The original SQLDataSources, HierarchicalDataSources and WebHierarchicalDataGrid were defined in the webpage designer. The page displays all data on initial startup and row expansion works fine.
In code, I modify the selectcommands of the parent and child SQLDataSources to add where clauses, then rebind the HierarchicalDataSource and a WebHierarchicalDataGrid.
When the filtered data comes back for display, I have the proper number of header records, but when I try to expand the row to see the children, I get an error popping up that says "Runtime Exception: TypeError: 'undefined' is null or not an object" I don't know how to get past that. Could you please elaborate on the proper method for filter the hierarchical data sources and grids?
In that case you don't have to create the relation in code behind, all you have to do is to statically define it in the markup.
Anyway I think that most probably the problem is in the way you are selecting (and filtering) the root items. Can you send me an example of the actual SQL query that you generate? Maybe you are performing inner join or something with the children table - that way you end up with a root record for each child...
I figured out how to clear the relations. How do I rebuild it programatically?
Maybe I need to rephrase the question.
I have a page with UltraWebTree bound to WebHierarchicalDataSource. The default data source is set to display all data from database (Clients as parent nodes and Projects as a child nodes). I need to filter this information based on an entry in a text box. User enters a search string and hits a Search button. The button click event applies a WHERE clause to both the parent and child data sources of the WebHierarchicalDataSource. That all works and only the searched for projects are displayed in the UltraWebTree. BUT, For some reason the parent node is retrieved as many times as there are child nodes
Example:
I am searching for ProjectName containing string "Station". There are three projects from the same Client. So the child data source returns "Station1, Station2, Station3". The Parent node Client should be displayed only once as such in the WebTree:
Shell Station1 Station2 Station3
Instead I get the following:
Shell Station1 Station2 Station3Shell Station1 Station2 Station3Shell Station1 Station2 Station3
in the WebTree
How can I fix this? Do I need to recreate the relationship in the WebHierarchicalDataSource from the codebehind, or do something else?
Hi,
The information you have provided is insufficient for me to solve the issue.
bilko73 said: I have a WebHierarchicalDataSource created and set relations visually on aspx page.
How exactly you are doing that?
bilko73 said:The only problem is that each parent node appears as many times as there is a max och child nodes.
I don't understand that, can you please explain in more detail?
bilko73 said:My guess is that the Relationship in WebHierarchicalDataSource needs to be reset.
WHDS Relation itself can not be reset, maybe you are trying to clear the relations collection? If so you can use the Clear() method.
If that doesn't help please provide more info and the complete source code (or sample project).