How to create controls dynamically on button click event?

I want to add a number of the text box on the button click event.
is it possible dynamically? if yes how to create a new control and how to access properties of dynamically created controls.

Hey @Hvishal – I’m not quite sure I follow. Could you give a more concrete example?

Likely, you can do this with a Javascript query that is triggered by clicking on the button. For example, you could have a simple query that just does:

text1.setValue("new value goes here"); 

This will change the value of a text1 to new value here.

Here’s our reference on Scripting Retool from the docs for more info.

It sounds like you might be looking for a listview component, which you can drag other components inside of and iterate copies of.

When you pressed a button, you’d want it to run a Run JS Code type query that returns a number higher or lower to change the number of rows and use that value in the listview’s instances setting. That query might look something like return += 1 and have the query run on load as well.

Hyy @alex-w ,

I am making a chat type small application, in which we have a textbox in which user can add the comment as soon as he click on submit his comment with the current time is noted there. But whenever, I am a new comment, every comment time is also changing as per the latest comment.

@alex-w please help me too avoid this date changing based on latest value. Its urgent release.

Hey @ishi8!

Have you had a chance to check out our docs on creating custom list views? They go a little more in-depth into what you need to do to set one up.

I'm curious how the components in your listview are configured here since the data that's displayed is largely configured within the nested component itself using the i variable.