openblocks-dev / openblocks

πŸ”₯ πŸ”₯ πŸ”₯ The Open Source Retool Alternative
https://cloud.openblocks.dev
GNU Affero General Public License v3.0
5.88k stars 360 forks source link

Limitations of ListView in developing interactive functionality for specific elements. #316

Open jitre opened 1 year ago

jitre commented 1 year ago

I created a collection of elements using ListView, as shown in the figure below. However, I found that there is no way to determine which element is currently being clicked, and the form components inside ListView cannot store and extract fields for specific elements, making it impossible to develop functions based on specific elements, such as liking. image

lmx1117 commented 1 year ago

Just use listView.items[].button1 and listView.items[].form1 to realize your expected operation πŸ˜‰, and thanks for reporting this, it seems that we should update our doc right now.

jitre commented 1 year ago

Just use listView.items[].button1 and listView.items[].form1 to realize your expected operation πŸ˜‰, and thanks for reporting this, it seems that we should update our doc right now.

Thank you very much for your help, it has been very helpful. I still have one question: I know that I can access a specific item in the list by index, but how do I know which index corresponds to the item that is currently being clicked? @lmx1117

lmx1117 commented 1 year ago

Thank you very much for your help, it has been very helpful. I still have one question: I know that I can access a specific item in the list by index, but how do I know which index corresponds to the item that is currently being clicked? @lmx1117

image image

Because I do not know your specific use scenario, you can just take a look at these two demos, for example, I want to display the title value of a listview item after clicking the button (p1), it can be achieved through {{currentItem.title}}, if you want to run a query, you can refer to p2 for passing parameters

jitre commented 1 year ago

@lmx1117 Thank you very much. I solved it using temporary state.

SvV-CWinJS commented 1 year ago

I have a related question: I have a dropdown (Select) in a List View. Upon change I run some Javascript code and would then like to clear the value of the dropdown. However, I get this error: "Nnotas.items[currentIndex].Nbijlagen.clearValue is not a function". The functions of a specific element in a List View are not accessible, are they?

lmx1117 commented 1 year ago

I have a related question: I have a dropdown (Select) in a List View. Upon change I run some Javascript code and would then like to clear the value of the dropdown. However, I get this error: "Nnotas.items[currentIndex].Nbijlagen.clearValue is not a function". The functions of a specific element in a List View are not accessible, are they?

May I have a look at the JS code that runs on the change of your Select component?

SvV-CWinJS commented 1 year ago

Sure. if(Nnotas.items[currentIndex].Nbijlagen.value != "") { let w = window.open(/*some url*/); w.document.write(/*some string*/); Nnotas.items[currentIndex].Nbijlagen.clearValue(""); }

With:

Note: The statements inside the if runs, so Nnotas.items[currentIndex].Nbijlagen.value exists (the value is correctly reused in a string in the if as well).

The final statement fails, with: clearValue is not a function.

lmx1117 commented 1 year ago

@SvV-CWinJS Sorry for the inconvenience, for now, you cannot access the components' function in listView, it’s something with listView itself, and it should be refined in the first release in April

jitre commented 1 year ago

@lmx1117 hello Can I access the current actual content of an input element inside a list view

jitre commented 1 year ago

It seems unable to obtain the current changed value of the input element, list.items[i].input.value.

SvV-CWinJS commented 1 year ago

I too experience what jitre writes. (under version 1.1.7) Accessing an input element's data (when in a list view) gives you its default value, not the "live" content. This is also true when the input element is part of a form (when the form is again in a list view).

JSON attached to clarify. test ListView2.json.txt

jitre commented 1 year ago

I too experience what jitre writes. (under version 1.1.7) Accessing an input element's data (when in a list view) gives you its default value, not the "live" content. This is also true when the input element is part of a form (when the form is again in a list view).

JSON attached to clarify. test ListView2.json.txt

I have discovered a way to obtain the dynamic values of input elements within a ListView. If the data in the ListView does not contain this field, the input elements can be modified and their values can be obtained. However, if this field exists, it will be set to read-only.

lmx1117 commented 1 year ago

Thanks for reporting this I will check with the engineer and come back to you later.

lmx1117 commented 1 year ago

@jitre @SvV-CWinJS Confirmed that this is a bug, thank you for your proposal, and I will let you know after fixing it.