List-view .data property not including child component values

Hello,

I am working to build a page that allows me to bulk insert new rows of data into a database with a list view. I cannot seem to access the values of the child components in the list view using listview1.data. I need to access the child component's data in the list view iterations as I am transforming the data into a bulk insert query to add these projects into the database.

I saw on this thread that the new list view does not support accessing child elements Access child elements of "List View (new). I am trying this on list view (legacy), this was working at one point for me, so I am not sure why it's not working now.

This issue started when the new list view was published, I am not sure if there is any relation there. I am confused because I have read the documentation, and the behavior I'm seeing does not match up with what I've read on the list view documentation.

Here's a screenshot of the configuration with containers


Here's a screenshot with no container - .data is showing ""

I appreciate help in pointing out what I'm missing!

There is a known limitation that I believe is in the works of being updated whereas the i element cannot be accessed.... what exactly are you trying to do... search the forums and I believe this has come up a few times...

@mHearn have you tried with the new list view? Mine shows .data for both as well as the Container List View. @ScottR where are you unable to access 'the i element'? Maybe it's been fixed... or I'm misunderstanding something? I've included pics of the .data as well as {{i}} and accessing the i'th element.

List View (New):
image

List View (Legacy):
image

Container List View:
image

If it is fixed that's great news!

@bobthebear @ScottR I can access the {{i}} element fine, but I want to access the values from the child components (job number, estimated mail date, groupID.... as seen in the screenshots) and they are not included in listview2.data.

Each i in this case is the primary key for my database, and I am wanting to insert data for each primary key (the child components). When I call .data, the only data there is the {{i}} value and nothing else.

The reason I am not using the new list view is because accessing child component values within a list view is not supported according to this thread.

So what are you trying to update? job number, estimated mail date, etc...? If so, how are you accessing those fields using [i]

I'm experiencing the same issue.
Tested it with the simplest possible listView:

The listView data source (just a test example):

Checkboxs state seems fine at a glance:
image

But this will fail:

NM, it's the new listView update. have not used retool for a while and didn't know this listView has new limitations.
@retool, it's nice that you're shipping but this is prod :wink: ship finished products or at least make it painfully clear when you don't.

I have a transformer script that calls listView2.data[i] and loops through the iterations, transforming it into an array to do a bulk insert query. It was working at one point, but now listView2.data[i] has no members. The members of the object are undefined just like @Mendy 's example.

but listView2.data is just all of the data so how do you know if it is updated? Or are you updating all? Why not do a Bulk Upsert?
Also what does the transformer look like and what does it return?

Are you using listView (new) or list view (legacy)? I am trying this on listView (legacy).

I started with new - didn't work. It works for me in legacy.

This page is for creating new projects. There is no data being updated because it's not yet in the database. This is the creation point.

But the issue is that there isn't anything inside of .data - so my script can't access any of those fields (job number, estimated mail date, group ID).

As you can see here, it just says jobPreviewContainer2: undefined.

I also tried removing the container, and it still does not work. Showing container1 is undefined, which I don't understand because I don't think there's a container there?
Screenshot 2024-01-04 at 9.19.14 AM

@mHearn Looks like there is a container there.... that being said, take a look at this post regarding a similar problem with Legacy List View - I posted some info there as well.... still not clear on what your transformer looks like to access the fields beng updated (job number, etc.)

How can I find that container then? When I search for it, it doesn't come up, and I don't see a container1 anywhere in the component tree.

Reload the app and see if it remains....it'd been known to happen.... unless the listview is in a different container....also, are you using the search at the top to look for container1?

No way! Reloading the page worked :no_mouth: . All instances of container1 are gone and .data has all the child components in it now. Well, now I know :sweat:. Thank you!

ok so looking more closely, I had to do some poking around but if you have a 100% new listview, it automatically populates .data with a default size of 3 and with each item having 1 auto generated property named retoolInternal_rowKey and a value of undefiend.
image

when you set the Item Keys value, 2 things automatically happen:

  1. .rowKeys for the listview is updated with the array evaluated from Item Keys.
  2. retoolIternal_rowKey for each array item in .data is updated with the corresponding array value from .rowKeys

something to note, I found 0 ways to force .data for a legacy listview to have a value of "". I tried using js and the Number of Items value, no matter what .data defaulted to an array of size 0.

i'd suggest trying 2 things.

  1. it sounds dumb, but try adding listview4 then set Item Keys to [0, 1] and Number of Items to 2 , then start adding your inputs. sometimes I would have to change Number of Items to get the State window to update (just enter 1, then re-enter/paste whatever you had in there). i'm wondering if that 1 listview got bugged somehow since .data is a value that shouldn't be possible as far as i know.
  2. i'm guessing you want to iterate over each input to grab the value, then process it afterwards and do ur bulk insert. if so, this is a bit backwards for listviews. they're suppose to be a way to view data that you already have, not list inputs to create data. an input form might be more suitable for this, or even a table.

seeing how .data is a string somehow, I'd be tempted to lean towards a bug, but deleting and remaking the listview could potentially fix this (just check .data is normal before you start customizing it).

This is really helpful, thank you!

The .data not including the child components, or showing "" was solved by reloading the page, it is working now. This list view is inside a form, but using a table based input form is a good tip, I'll keep that in mind.