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
45
Showing two tables in the WinTree - Band nodes problem
posted

Background
I am trying to display two tables in an UltraTree control: Location and Machine.  The Location table is the hierarchy; the Machine table references the Location table.

The tables have the following columns (the relevant ones):
Location
--------
LocationPK
Name
ParentLocationPK

Machine
-------
MachineID
Name
LocationPK
(lots of other columns)

Each node in the tree will have one of two types of children - any number of locations *or* exactly 1 machine.

I want the tree to display the Location heirarchy using just the name column, and if they expand a name and it is referenced by a machine, show the machine details (quite a few columns of information).

Problem
Currently whenever a Location node is expanded, it shows two child nodes - "Location" and "Machine".  The user then has to expand the "Location" and "Machine" columns to see the next layer of details.

Is there a way to hide the "Location" and "Machine" nodes from appearing, and instead show their children, when only one of those bands has children? 

Edited to add:
From the documentation on the UltraTreeColumnSettings.ShowBandNodes, it says: "Regardless of the setting of ShowBandNode, band nodes will always be created to separate siblling bands. In a case where a child band has no siblings, a band node will be created for it if ShowBandNodes is set to ShowBandNodes.Always"

Obviously the UltraTree considers that there are two bands for each node - the Location and Machine bands.  However the business rule prevents this from ever happening.

Is there a way to hide a band from appearing when there are no child nodes for that band?

 

Example
I am seeing this:
- RootLocation
  - Location
    - ThisIsALocationName
    - AndAnother
      - Location
        - YetAnotherLocation
          - Location
          - Machine
            - AMachine | All | Columns | Appear | Here...
      - Machine
  - Machine

but want to see this instead:
- RootLocation
  - ThisIsALocationName
  - AndAnother
    - YetAnotherLocation
      - AMachine | All | Columns | Appear | Here...



Further Details
I have created a DataSet and populated it with two tables, Location and Machine.  I have added two relationships to the DataSet like so:


dataSet.Relations.Add("Location", rv.Tables["Location"].Columns["LocationPK"], rv.Tables["Location"].Columns["ParentLocationPK"], false);

dataSet.Relations.Add("Machine", rv.Tables["Location"].Columns["LocationPK"], rv.Tables["MachineColumns["LocationPK"], false);

 

I have looked through the examples in the WinTree folder in the Samples directory.  I have not been able to find an example that uses two tables in one tree via a bound DataSet.

We have also considered styling the screen after the sample in folder "DataBinding (Navigation) CS"; however we'd like to see if this specific problem can be overcome as we will most likely encounter this situation again in the future.

Parents Reply Children