-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]-[72]:Add currentItem and currentItemIndex in JSON Form Arrays #16343
Comments
@some-rando thanks for the great feature request! @dilippitchika @ashit-rath hopefully this should be simple to add |
Discussed with @ashit-rath, we are unsure about the complexity here and think we need a sprint dedicated fully to build this based on the current working of json form. We will pick this when he has some bandwidth from the list project. |
I would like to second this request, JSON forms are the only way to get user-managed arrays (users being able to add and subtract entries) into an appsmith form. The inability to have dependent fields within them means there are many data structures that just can't be replicated easily. |
@KyleWayneLaCroix can you please help me understand your use-case better with an example? |
This would be very useful! I cant find any workaround for this as of now. I have an array field, with a select field child. I need to use the "Server Side Filtering" for the select but that's not possible since i cant access the "filterText" property for the current active field. |
Any updates on this one? :) |
Hello @oskarannas my apologies, we haven't been able to prioritise this yet |
Stats
|
What is the jobPre-requisite
Circumstance
Need
So that
EvidenceRequests in the issue
SolutionWithin list and table, we already have a way to refer to the item and the widget. We follow the same principles here but the approach has to be a mix of both list and table. Devs will need access to all meta and derived properties within the widgets. Today accessing derived properties happens via Within the array items, we need a way to access the currentItem and the Solution idea 1 For this we will enable the Solution idea 2
Solution 1 looks much cleaner because the form data is separate from the field states making it easy to use the form data when necessary. This way is already established in the json form, making it local to it. However, this would need additional learning for people to use, because this method is different from list and table. Open questionsWhy did we divide it into formData and fieldState then? Why can’t fieldState contain the formData as well? If it also had the references then the developer can reference formData for only the data and find all field meta and derived properties using field state. Should we think about adding the meta properties in the fieldState as well? |
The initial thought process of dividing these two were:
If combination of data and state is a very common use-case then it makes sense to put data in the state as well. SolutionSolution 1 does look quite clean and can be relatable to the However I feel that the Solution 2 would help us align with the table and list. If tomorrow we decide to use actual widgets in JSONForm then the list widget will come into play and the learning curve would be less. |
I agree, since these properties are only needed for accessing in other elements which is not always, we can go with solution 2 by default |
Looked into this , need to understand the solution around it a bit better. So will be picking this up in the next sprint. cc: @dilippitchika |
Is there any update on this issue? |
Is there an existing issue for this?
Summary
Having access to array indexes on a JSON Form widget would allow manipulating data or using Javascript functions to make decisions based on user input. Similar to the List widget
currentItem
or Select widgetSelectWidget.selectedOptionValue
, etc.Why should this be worked on?
The JSON Form widget is super powerful and useful, but this issue is holding it back from its full potential.
In our specific case, I have a JSON Form widget displaying several items for saving URLs of public safety agencies. Fire Departments, Police Departments, other Emergency Services. A key difference for our use is that we also associate the URLs with certain areas (USA states, counties, cities, towns), and that it can be more than one area per URL. To keep things easier for my users I want to allow them to search for areas by name.
I'm using an Array Item on the JSON Form widget. Inside the Array Item are fields:
State
,Area Name
, andResults
. On theArea Name
field I use anonTextChanged
action to generate a Postgres query.This currently works great, but only for the first Array Item since I can't determine which Array Item called
onTextChanged
, and I can't display the returned results in theResults
field for the same reason. I've hard-coded index zero inJSONForm1.formData.Areas[0].State
to get the results I want on the first Area. If I could get something likeJSONForm1.formData.Areas[**currentItem.id**].State
then I think things would work wonderfully.In case it matters, I'm mapping the returned results from the query in the
Results
field, Radio Group type, within the Array Item. And I can only display the first result since I can't determine which Array Item index I'm on.Front conversations
The text was updated successfully, but these errors were encountered: