Newbie seeking advice, 3-level hierarchy, display level 1 & 3, don't display level 2

Posted by: jon-larson on 8 September 2017, 1:40 pm EST

  • Posted 8 September 2017, 1:40 pm EST

    Having just begun to glimpse the power and flexibility of fpspread, I'm sure there are a number of ways to skin this particular cat.  BUT - lacking even the most rudimentary knowledge of each/every capability of fpspread, I'm uncertain ast to the best (meaning least amount of coding to achieve the desired result) approach.  So I'm inviting any (and that means ANY) comment that might lead me to the optimum solution.<br><br>I hope the following is a reasonable analogy for the project:<br><br>Acme Inc. manufactures a number of PRODUCTS including Doo-Hickeys, Gadgets, Thing-A-Ma-Jigs, and Widgets.  Each of those products is assembled from assembled component MODULES including power module, cooling module, viewer module, mobility module, heating module, analyzer module, printer module, etc.  Any given module may be used in assembly of one or more products - thus the product-module relationship is one-to-many.  Of course, not all modules are used in any given product.<br><br>Each module is assembled from discrete COMPONENTS, including Resistor1, Resistor2, Resistor3, PrintHead1, PrintHead2, PrintHead3, CRT1, CRT2, CRT3, etc.  There are an unlimited number of discrete components within each type.  The module-component relationship is therefore essentially many-to-many.<br><br>All data is, of course, contained in a database.  Tables: Product, Modules, Components as follows:<br>Products<br>         ---> Modules<br>                      ---> Components<br><br><br>Now, as to the fpread layout and desired functionality:<br><br>The ParentRow will display the PRODUCT, ie: Doo-Hickey, Gadget, Thing-A-Ma-Jig, and Widget and will be expandable.<br><br>Upon expanding the ParentRow for any give PRODUCT, I wish to have the grid display the discrete COMPONENT list.  I do NOT wish to see anything from the MODULE list.<br><br>In its "natural" layout, the grid seems to want to display something like this (with headers at each level):<br><br>Widget<br>---> PowerModule1    $45.00  120VAC<br>--------> Resistor1<br>--------> Resistor5<br>---> PrinterModule3  $30.00<br>--------> PrintHead2<br>--------> Inker7<br>---> CoolingModule4  $80.00<br>--------> Fan6<br>--------> Evaporator2<br><br>BUT WHAT I WANT TO DISPLAY IS (with only one header for the COMPONENTS list):<br><br>Widget<br>--------> Resistor1<br>--------> Resistor5<br>--------> PrintHead2<br>--------> Inker7<br>--------> Fan6<br>--------> Evaporator2<br><br><br>How might I most easily achieve this?<br><br>
  • Replied 8 September 2017, 1:40 pm EST

    <P>Hello,</P>
    <P>Try code like the following in the ChildViewCreated event of the Spread. You would need to change the RelationName check to the name of the relation you use between the parent and first child.</P><FONT size=2>
    <P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Private</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub</FONT></FONT><FONT size=2> FpSpread1_ChildViewCreated(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> sender </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Object</FONT></FONT><FONT size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> e </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> FarPoint.Win.Spread.ChildViewCreatedEventArgs) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Handles</FONT></FONT><FONT size=2> FpSpread1.ChildViewCreated</P>
    <P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If</FONT></FONT><FONT size=2> e.SheetView.ParentRelationName = </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"relA"</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Then</P></FONT></FONT><FONT size=2>
    <P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>For</FONT></FONT><FONT size=2> i </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Integer</FONT></FONT><FONT size=2> = 0 </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>To</FONT></FONT><FONT size=2> e.SheetView.RowCount - 1</P>
    <P>e.SheetView.ExpandRow(i, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>True</FONT></FONT><FONT size=2>)</P>
    <P>e.SheetView.Rows(i).Height = 1</P>
    <P>e.SheetView.ColumnHeaderVisible = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>False</P></FONT></FONT><FONT size=2>
    <P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Next</P></FONT></FONT><FONT size=2>
    <P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If</P></FONT></FONT><FONT size=2>
    <P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub</P></FONT></FONT>
  • Replied 8 September 2017, 1:40 pm EST

    <p>Your solution works - in a fashion - but falls somewhat short of the
    desired result.  The code segment you provided does in fact disable
    display of the level-2 (Module) data.  However, for each Component
    listed, each component has its own header and horizontal scrollbar. 
    Sort of like this:</p><p>Component Header</p><p>Resistor1</p><p><Scrollbar></p>
    <p>Component Header<br>
    </p>
    <p>Resistor2</p>
    <p><Scrollbar></p>
    <p> </p>
    <p>Where the goal is to achieve a display sort of like:</p>
    <p>Component Header</p>
    <p>Resistor1</p>
    <p>Resistor2</p>
    <p><ScrollBar for the entire component group> </p><p> Thus eliminating the redundant Component Header.  <br></p><p>I'd been looking at a custom sheet... seemed quite a bit of tedious coding, so I was hoping for a more efficient solution.</p><p> </p><p>Thoughts? <br></p>
  • Replied 8 September 2017, 1:40 pm EST

    <P>Hello,</P>
    <P>There is not any easy way to do what you want unless there is a way to create your DataSet with just two tables and relate the first level to the third level without the middle table. I do not think you would be able to do this. Otherwise you would need to write your own SheetView object that gets values from the correct tables and sets changes back in. The custom SheetView would be a lot of tedious coding as you have seen.</P>
  • Replied 8 September 2017, 1:40 pm EST

    <p>Thank you, Scott.  I was afraid a custom SheetView might be the only real solution.</p><p> </p><p>Can you tell me.... which of the VB.net examples do you feel would be most helpful in guiding my way in implementing this custom SheetView? <br></p>
  • Replied 8 September 2017, 1:40 pm EST

    <P>Hello,</P>
    <P>The following <A class="" href="http://www.clubfarpoint.com/Forums/forums/thread/30883.aspx">thread</A> has a sample project that has C# and VB code for implementing this.</P>
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels