I am exploring form.io's form-builder concepts and components.
I dragged and dropped a data-grid component into my form during that process. The data-grid component has three sub-components named id, userId, and title ( Three of them are text fields and disabled which means we can edit )
I have loaded the data for the data-grid component through an external API. The API provides a response as an array of objects and each object will have the id, userId, and title fields. I have mapped the values to my data-grid component as below :
## data-grid component settings: under the data tab and in the custom default value section's javascript :
var gridData = [];
function loadData() {
var apiUrl = "https://jsonplaceholder.typicode.com/posts";
fetch(apiUrl)
.then(response => response.json())
.then(data => {
data.forEach(function(row) {
gridData.push({
"id": row.id,
"userId": row.userId,
"title":row.title,
"body": row.body
});
});
return instance.setValue(gridData);
})
}
loadData();
It loads the data as expected :
Current data-grid component loaded with external api data :
Now I want to provide an edit option for the title for specific rows which satisfy some conditions based on the values of id and userId.
For example, if the id and userId are equal in any rows, the title field of those rows must be editable which means the disabled property of those specific title fields must be changed to false.
Available possibility :
We can make specific title fields editable in the logic tab of the title component's **setting:
**
Under the logic tab, we have logic and action fields. We can utilize it. But I don't know How to compare the id and userId for each row and enable those specific rows.
Someone, please help me to fix this.