cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
Question:
We are using SisenseJS to embed widgets into a React app.  I am looking for a way identify the widget to render without using its id or title. This is so when the product team changes the dashboard/widget/title to show, we don't have to update the code.
Are there any properties/attributes/tags that can be specified in the dashboard designer that could later be used in the javascript to identify the widget?
Answer:
There is no built in feature for this but we can think of two slightly hack-y solutions:
One would be to utilize the Description field for widgets, which is often left blank:
Or, if you do use widget descriptions, you could attach a custom property to the widget object via the widget script:
When you do the above, and then save the widget, this property will be stored and can be found when getting the widget via API. However, since this is a property that isn't part of the widget object model is might get overridden or removed unexpectedly. You might be able to avoid that, by attaching the custom property to the widget's "style" object, like so:
widget.style.myCustomProp = 123;
Making sure not to conflict with any existing properties in there.
Of course, these approaches are as good as your maintenance discipline - if your designers replace the widget, but forget to both remove this property from the old one and add it to the new one, you're no better off than using the titles. If that doesn't happen, then the widget ID is the most stable, reliable unique identifier and I would generally recommend using it in all other cases except when you actually replace (delete + create new) widgets on a regular basis.
Version history
Last update:
‎03-02-2023 08:36 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email [email protected]

Share this page: