Retool does provide a list of components that can full fill any data representation needs. But still, there are some scenarios where you want to work with a custom component, or maybe you want to integrate a legacy component in your new Retool dashboard.
For these needs, Retool provides a custom component. You can create ReactJs-based components using this custom component and JS-based components with a mixture of HTML.
According to my personal experience and existing Retool documentation, I discovered that some information is missing. And most of the time, when a developer starts working with this component, they face these challenges repeatedly.
We will see these topics individually and try to understand how we can work with this brilliant component. So let’s get started.
In a custom component, you have to pass data to your component. You can hardcode this data or refer any query to this component. The second part is the IFrame code. To render, you must write an HTML-based code in the IFrame Option. You can write Plain JS events and also React component code.
In this example, I have provided some Dummy data in the Model option to render a Plotly custom component.
Let’s break down the IFrame code for better understanding. If you’re familiar with writing HTML pages, this part will be a piece of cake for you.
First, you can define the Style of your component using < Style> tags. The second part would be your CDN libraries and packages, as you can see from Retool’s documentation.
The rest of the code is pretty self-explanatory. I took this example from a Plotly website.
Look closely at this part. We can easily access our Model input inside our IFrame code using “Retool.subscribe” Method.
var xSavings=[];
var xNetworth=[];
var ySavings=[];
var yNetworth=[];
window.Retool.subscribe(function(model) {
xSavings = model.plotData.xSavings;
xNetworth = model.plotData.xNetworth;
yNetworth = model.plotData.yNetworth;
ySavings = model.plotData.ySavings;
});
So now you learned how you could pass data to Retool’s custom component. Now Let’s talk about how we can Pass data from your Custom Component to your app.
Using the model update method, you can pass data from your custom component to other components. If you’re developing a non-React custom component, use the following Method.
function updateName(e) {
window.Retool.modelUpdate({ name: e.target.value });
}
Using the trigger query method, you can pass the query as a parameter you want to run.
function buttonClicked() {
window.Retool.triggerQuery('query1')
}
The retool engineering team is constantly updating their existing components and building new ones. But every use case has its requirements. Custom components are always there to full fill special requirements.
Passing data to Retool a custom component, Passing data from a custom component to another component and Triggering a query from one custom component is very easy. By combining these three features, you can develop any custom component in Retool.
This website uses a limited number of cookies to ensure proper functionality. These cookies are essential for operating our website, which is WordPress, a popular content management system.