DataTable Custom Widget

Hi everyone.

I just wrapped up my first custom widget, for generating HTML tables that have advanced interaction controls (pagination, keyword searching, sorting, and more). It uses the DataTables jQuery Javascript library ( https://www.datatables.net/ ) to enhance the HTML table.

You can either pass the widget a fully-formed HTML table, or a JSON array. When you pass an array, the widget automatically generates an HTML table for you.

The widget supports a “Link Clicked” event, so you can add a trigger and take action based on the click. For example, you might grab the ID of the row that was clicked, navigate to another step, and show more detailed information, present a form, etc.

The widget is available here:
https://timdietrich.me/resources/blog-assets-20220615/customWidget-DataTable-v1.1.json

Also, there’s more information (details about its properties, the “Link Clicked” event, etc) about the widget here:
https://timdietrich.me/blog/tulip-datatable-custom-widget/

I hope you find the widget to be useful. If you have any questions, comments, etc, please let me know.

Thanks,

  • Tim
12 Likes

Looks pretty slick, alot of table related features here that should be native options.

@chris.wartella -

You’re totally right. As a little bit of context, Custom widgets came out of a long line of widget asks that really only fit the needs of 1 or 2 customers (we aren’t going to make a hyper specific gauge to match your machine hmi, because very quickly there would be hundreds of native widgets). Instead the approach was to enable users to make their own very specific widget for their very specific problem.

We are watching closely what people are making, and when custom widgets get traction with more than 1 use-case, that is a trigger for us to evaluate natively supporting that functionality. Many of these limitations are understood (like a lack of looping natively) and are being addressed currently with a lot of engineering work behind the scenes, while others (like disable-able widgets) have come up in the past, but we didnt realize how many users would be interested in using.

If we let you make it, we can see what you make, and then natively support it. Triggers on Checkboxes and single selects (and soon more input types) are the first examples we are seeing of custom widgets driving us to improve the native widgets.

Pete

1 Like

Hi Tim, this is a great widget and I am starting to use it in one of my apps. One issue I am having is getting the data loaded into the custom widget. I can load a variable just fine but it seems to be a timing issue in getting the variable set and passed to the widget with data. Have you had success in using it and if so, how did you set the variable that contains the json array (e.g. step enter trigger)?

Thanks in advance,
Kevin

@kirons Thanks for the feedback on the DataTable widget.

I have also occasionally run into timing issues, especially when the data being used by the widget needs to be loaded from an API. One of the techniques that I am exploring is to load the data in one step, then move to a second step that actually presents the data using the widget. That should help to ensure that the data is loaded before trying to use it with the DataTable widget.

~ Tim

I chatted with Tulip support about this and they helped with the issue. This is from the custom widget documentation page: Custom Widgets Overview | Tulip Knowledge Base - Support for Building Operations Apps

Just changing the value of the variable doesn’t necessarily trigger the custom widget to update. You can implement the custom widget so that it does respond to updates from a variable though, using the code below:

getValue(‘My Prop’, (internalVariable) => { doSomething(internalVariable);});

1 Like

A little update I made to this widget for @jjj -

I made an update to this widget to support XML-encoded data.

Important Note: This only supports lists that are one level deep, example data below

<Items>
   <Item>
      <ItemID>aaa111</ItemID>
      <ItemPrice>34.22</ItemPrice>
   </Item>
   <Item>
      <ItemID>bbb222</ItemID>
      <ItemPrice>2.89</ItemPrice>
   </Item>
</Items>

Pete
customWidget-DataTable v1.2 (2).json (24.4 KB)

1 Like

@Pete_Hartnett is literally a wizard :magic_wand:
YARN | You're like a wizard. | Game of Thrones (2011) - S03E09 | Video gifs by quotes | 31137596 | 紗

1 Like