VolkovLabs / business-forms

The Business Forms panel is a conceptually new plugin for Grafana. It is the first plugin that allows inserting and updating application data, as well as modifying configuration directly from your Grafana dashboard.
https://docs.volkovlabs.io
Apache License 2.0
86 stars 10 forks source link

Pre-Select Checkbox when i get data from Infinity datasource #443

Closed skynet-05 closed 3 months ago

skynet-05 commented 4 months ago

Considering this my response

[
    {
        "value": "12345",
        "label": "foo",
        "isChecked": true
    },
    ...
]

Im using the form element: "Checkbox list with custom options" How do i pre-check the boxes as the data is fetched?

vitPinchuk commented 4 months ago

@skynet-05 Thank you for your question

Are you having an issue with the initial value for the Checkbox list with custom options? Do you set the initial value but it doesn't work for your Checkbox list? We fixed that in a similar issue #428 and #435 It should work correctly from version 4.1.0

Or are you trying to figure out how to set the initial value for Checkbox list using the Infinity data source as a whole?

Thank you.

skynet-05 commented 4 months ago

No, I'm able to see the checkboxes once the data is fetched from the datasource but is there an option to automatically select the checkboxes when for certain is mapped as checked = true

Considering this my response

[
  {
      "value": "12345",
      "label": "foo",
      "isChecked": true
  },
  ...
]

Im using the form element: "Checkbox list with custom options" How do i pre-check the boxes as the data is fetched?

if my data sends isChecked = true I want this particular value to be preselected, so that i can have an option to unselect and update the values.

vitPinchuk commented 4 months ago

@skynet-05 Thank you for your question and the detailed information.

We have added a few updates to our documentation to clarify moments related to setting initial values and mapping them to form elements. The updates will be available shortly.

We have added some changes to our panel. The Field and Query Field (Query) fields will be placed in the Initial Query section in the options. The updates will be available since 4.2.0 version.

Basic issue. To set initial values via Infinity Data source and another type of data source, please, use Query Field option in element. Please select Initial Action to Query, after that Select a field from the Query response and it should automatically preselect values.

Initial Action Section image

Query Fields image

skynet-05 commented 3 months ago

Hey, Thank you for your update regarding this. I'm still facing few issue w.r.t. this. Let me reiterate the issue again.

[
    {
        "_id": "12345",
        "lable": "foo",
        "isChecked": true
    },
    {
        "_id": "123456",
        "label": "foo",
        "isChecked": false
    },
    ...
]

Considering the above response from my API using infinity plugin This is what i see in my panel

image and below are the configurations

image

image

But with the above configurations, for the initial checkbox selections its only pre selecting the last ones

Current version of Business Form is 4.3.1

Do let me know if I have to update the way i send API response or i misconfigured something

Thank you :)