cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Organize Your UI with the Collection Widget Part 3

100% helpful (1/1)

 

 

Step 4: Use Collection Widget

 

At this point, you have created the following Entities:

 

  • A Thing with data stored in an Info Table Property (columns defined by a Data Shape)

 

  • A base Mashup (containing Gauge, LED Display, and Text Field Widgets) that displays an individual row of data from the table

 

Now, you need to use the Collection Widget to display this Mashup for every row of data in the table.

 

  1. On the ThingWorx Composer Browse tab, click Visualization > Mashups, + New

 

20-ocw-mashups.png

 

   

     2. Keep the default of Responsive with no Templates chosen, and click OK.

 

     3. In the Name field, enter cwht_collection_mashup

 

21-ocw-mashup-name.png

 

   

     4. If Project is not already set, search for and select PTCDefaultProject.

 

     5, Click Save.

 

     6. Click Design

 

22-ocw-design.png      

     7.  On the top-left Layout tab, ensure that the default of Positioning > Responsive is selected.

  •  You want the "base" Mashup to generally be Static, while the "collection" Mashup should be Responsive to allow it to grow to an appropriate size.

 

02-htcw-mashup-layout.png

 

    8. From the top-left Widgets tab, drag-and-drop a Collection Widget onto the central Canvas area.

 

23-ocw-drag-drop-collection.png

 

 

Access Mashup Data Service

 

  1. Click the + icon at the top-right to open the Add Data pop-up menu.

 

24-ocw-data-tab.png

 

25-ocw-add-data-popup.png

 

 

      2. In the Entity Filter field, search for and select cwht_thing.

 

      3. In the Services Filter field, enter getproperties.

 

      4. Click the right arrow beside GetProperties to add the GetProperties Service to the right-side of the pop-up menu.

 

      5. Click the Execute on Load checkbox

 

26-ocw-getprops.png

 

 

      6. Click Done to close the pop-up menu.

  • The GetProperties Service of the cwht_thing is now shown on the right under the Data tab.

 

      7. On the top-right, expand GetProperties.

 

27-ocw-data-getprops.png

 

      8. Drag-and-drop GetProperties > infotable_property onto the Collection Widget

 

28-ocw-drag-drop-infotableprop.png

 

 

     9. On the Select Binding Target pop-up, click Data

 

29-ocw-bind-data.png 

Configure Properties

 

  1. In the Collection Widget's Filter Properties field in the bottom-left, enter mashup.

    • This will limit the displayed Properties of the Collection Widget (in the bottom-left section) to only those containing the word "mashup".

 

22-filter-mashup.png 

 

     2.  For the Mashup Property, search for and select cwht_base_mashup.

  •  Choosing "cwht_base_mashup" lets the Collection Widget know which base Mashup to repeat in every Cell

 

04-cwv92-mashup-prop.png

 

 

        3. In the MashupHeight field, enter 250 and hit the Tab keyboard key to apply the change.

  • This Property changes the height of each Cell of the Collection Widget.
  • Ensure the height is large enough to fit all of the Widgets.

         4. In the MashupWidth field, enter 500 and hit the Tab keyboard key.

  •  This Property changes the width of each Cell of the Collection Widget.
  • Ensure the is large enough to fit all of the Widgets.

 

24-set-height-width.png

 

       5. In the Filter Properties field, enter uidfield.

 

       6. In the UIDField drop-down, select first_number

  • The UIDField sets the unique identifier for the Collection Widget.

 

25-set-uidfield.png

 

       7. In the Filter Properties field, enter sort.

 

       8. In the SortField drop-down, select first_number.

  •  SortField determines which sub-section of the Infotable to use for sorting purposes.

 

       9. Check the SortAscending checkbox

 

26-set-sorts.png

 

       10. n the Filter Properties field, enter mashupprop

 

27-filter-mashupprop.png

 

      11. Click Add, copy-and-paste the following JSON into the MashupPropertyBinding Property, replacing the existing curly braces {}, then click Done.  

  • The point of this JSON is to relate the columns of the Infotable Property to the Mashup Parameters that we previously defined in the base Mashup.
{
    "first_number" : "first_number", 
    "second_number" : "second_number", 
    "third_number" : "third_number"
}

 

28-set-json.png

 

 

 

       12. Click Save, then View Mashup.

 

29-view-mashup.png

 

Notice that the base Mashup we previously created has been replicated multiple times, corresponding to each row of the Info Table Property.

 

As an extension exercise, go back into cwht_thing and add another row of data. Refresh the Collection Widget Mashup to see another instantiation of the base Mashup automatically added to display that new row.

 

A Mashup utilizing the Collection Widget dynamically expands to accommodate both the user and the available data.

 

Step 5: Next Steps

 

Congratulations! You've successfully completed the Organize Your UI guide, and learned how to:

  • Create a Datashape to define columns of a table
  • Create a Thing with an Info Table Property
  • Create a base Mashup to display data
  • Utilize a Collection Widget to display data from multiple rows of a table

Learn More

 

We recommend the following resources to continue your learning experience:


Capability Guide
BuildApplication Development Tips & Tricks
ExperienceThingWorx Application Development Reference

 

Additional Resources

 

If you have questions, issues, or need additional information, refer to:


  Resource Link
CommunityDeveloper Community Forum
SupportCollection Widget Help Center

 

Version history
Last update:
‎Dec 02, 2022 05:00 PM
Updated by:
Contributors