Javascript functions can be used with listview

Can anyone get me the list of js functions which supports with listView?
Thank you

Hi @Vinkal!

Which functions are you looking to use with Listviews? All of the JS functions should be available within these components!

Hi @ben,
I was looking for the JS function to remove specific element from the list view using its index.
Thank you!

I see! The Listview will display an element for each item in the array, so performing array functions on the input data will remove or add elements to the listview. So using JS array functions (ie trim() or splice()) can manipulate the elements of the Listview!

Hey @ben ,
Yes array functions are working for it, but do we have any js function to set listView data?
Thank you!

You can use a JS transformer to change the data in any way you want for example you can write a function that loops through your data and removes the element that you wish to delete.

Or you could just use a standard JS array function like the one below (from Mozilla's JS Array Docs):

Hope this helps @Vinkal !

1 Like

Hey @sidpuri !

Thank you for your help.
Currently I have used splice function only to remove an element. But I need to set that data again in the listView, so I need a function to set listView data using JavaScript as I need to display it to user in retool.


You can possibly splice it but then store it as a temporary state variable to place it again where you need it?

Hey @sidpuri , Yes I can do that, but how to place it again in the list view(i.e is there any js function supported to set data in the listView?)

Thank you

You can use it just the way you do it for other components but using i to specify the index. When you set the 1st element as {{[i]}} it will populate the remaining list view.

Here's an app I built recently using the ListView :

Here's the documentation that talks about how to use i in ListView -

Hope this helps!


@sidpuri Okay, I will check for it.
Thanks a lot!

1 Like