6 Replies Latest reply on Oct 15, 2015 8:57 AM by keriw RSS
    keriw Apprentice

    Data Driven Menu Issue

    I am trying to use a data driven menu.  I have a table that is configured with columns that match the MenuEntry Data Shape.


    column names:

    description

    imageURL

    isDefault

    linkDestination

    linkTarget

    linkType

    menuId

    parentMenuId

    titlle

    This is the data in the that table:


    A

    NULL

    False

    http://server:8181/Thingworx/Runtime/index.html#master=&mashup=Metrics Dashboard&Team=A

    New

    Hyperlink

    Teams_0

    Teams

    A

    B

    NULL

    False

    http://server:8181/Thingworx/Runtime/index.html#master=&mashup=Metrics Dashboard&Team=ACS.T1

    New

    Hyperlink

    Teams_1

    Teams

    B

    Teams

    NULL

    NULL

    NULL

    ---

    Menu

    Teams

    NULL

    Teams










    I then created a service that returns an infotable and uses the data shape MenuEntry.  I then placed the menu widget down on the mashup and linked the service data to the menudata and selected datadriven.  No data is being returned in runtime.  Any thoughts/ideas?

     


    Thanks





      • Data Driven Menu Issue
        paic Collaborator

        I've never worked with the menu as Data Driven but what I do see sometimes with a Tree widget, is that it can't render if a value is NULL.

         

        Perhaps you can try with the value set to "" instead.

        • Data Driven Menu Issue
          keriw Apprentice

          Thanks for the idea PaiC, unfortunately it didn't resolve the issue.

           

            • Data Driven Menu Issue
              paic Collaborator

              Have you verified that the information comes into the mashup by putting it into a grid? This is a great way to check if information arrives in an infotable.

               

              Also I would create this menu as a defined/configured menu and run the GetEffectiveMenu service into another grid, allowing you to compare what you are generating vs. what Thingworx natively would generate for a Menu widget.

            • Data Driven Menu Issue
              keriw Apprentice

              Yes, I verified that it is coming into a grid correctly.  Everything looks perfect.

               

                • Data Driven Menu Issue
                  adam Creator

                  Keri,

                   

                  Based on my testing, the null values do not appear to affect the Menu widget. However, if you're capitalizing NULL and False as you are in the example data you provided, this will likely create issues as JavaScript keywords are case-sensitive.


                  I was able to get a data-driven Menu working in a Mashup by observing the JSON data returned by the GetEffectiveMenu Service when using the widget with the configured option. Using this structure as a reference, I programmatically created a Menu with two hyperlinks and a menu. Below, I'll briefly describe the process:


                  Add a Row for the Top-level Menu

                  After creating an InfoTable with the appropriate DataShape (MenuEntry), I add a row for the top-level menu:


                  var row = new Object();

                  row.menuId = "Menu1";

                  row.linkType = "Menu";

                  result.AddRow(row);


                  Next, I add the hyperlink menu items:


                  var row = new Object();

                  row.parentMenuId = "Menu1";

                  row.menuId = "Menu1_1";

                  row.title = "Google";

                  row.linkType = "Hyperlink";

                  row.linkDestination = "http://google.com";

                  row.linkTarget = "New";

                  row.isDefault = false;

                  result.AddRow(row);


                  ...


                  Add a Row for the Nested Menu

                  var row = new Object();

                  row.parentMenuId = "Menu1";

                  row.menuId = "Menu1.Menu2";

                  row.title = "More";

                  row.linkType = "Menu";

                  result.AddRow(row);


                  Lastly, I add a row for the menu item of the nested menu:


                  var row = new Object();

                  row.parentMenuId = "Menu1.Menu2";

                  row.menuId = "Menu1.Menu2_0";

                  row.title = "ThingWorx";

                  row.description = "ThingWorx";

                  row.linkType = "Hyperlink";

                  row.linkDestination = "http://thingworx.com";

                  row.linkTarget = "New";

                  row.isDefault = false;

                  result.AddRow(row);


                  Obviously, you'll generate this InfoTable differently depending on your use case, but this should help you get the necessary information in the InfoTable for the Menu. Speaking of your use case, would you mind sharing it? I'm curious to know why you would need to use a data-driven Menu.


                  Regards,

                  Adam




                • Data Driven Menu Issue
                  keriw Apprentice

                  Great, I will give that a try.  Our main menu for our system is a list of teams that is dynamic in nature, a team name can change or a new team could be added or deleted from the database.  I have substituted with a basic list in the interim but would like to have the more robust features that the menu provides and the capability for icons.