[JoaoCarimo]
Hi Stefan, Thank you coming back to me.
I am learning JSONForms as i want to use it as a form engine within Angular 7.
I am using the: GitHub - eclipsesource/jsonforms-angular-seed: Angular-based JSON Forms seed app as a base.
There is a ag-grid ui which i intend to automatically render:
I have imported it as a component but i have been struggling to map it as for example ‘type’: ‘grid’
and defining related properties.
This is an example:
private schema = {
‘type’: ‘object’,
‘properties’: {
‘name’: {
‘type’: ‘string’,
‘minLength’: 3
},
‘personalData’: {
‘type’: ‘object’,
‘properties’: {
‘age’: {
‘type’: ‘integer’
},
‘height’: {
‘type’: ‘number’
}
},
‘required’: [‘age’, ‘height’]
},
‘vegetarian’: {
‘type’: ‘boolean’
},
‘birthDate’: {
‘type’: ‘string’,
‘format’: ‘date’
},
‘nationality’: {
‘type’: ‘string’,
‘enum’: [‘DE’, ‘IT’, ‘JP’, ‘US’, ‘RU’, ‘Other’]
},
‘occupation’: {
‘type’: ‘string’
},
‘investments’: {
‘type’: ‘object’,
‘properties’: {
‘type’: ‘grid’,
‘className’: ‘ag-theme-balham’,
‘templateOptions’: {
‘height’: ‘200px’,
‘class’: ‘ag-fresh’,
‘gridOptions’: {
‘rowHeight’: 42,
‘paginationPageSize’: 15,
‘pagination’: true,
‘columnDefs’: [
{‘headerName’: ‘User Group’, ‘field’: ‘group’, ‘sortable’: true, ‘filter’: true, ‘checkboxSelection’: true },
{‘headerName’: ‘Role’, ‘field’: ‘role’, ‘sortable’: true, ‘filter’: true},
{‘headerName’: ‘Status’, ‘field’: ‘status’, ‘sortable’: true, ‘filter’: true }
],
},
}
}
}
},
‘required’: [‘occupation’, ‘nationality’]
};
private uischema = {
‘type’: ‘VerticalLayout’,
‘elements’: [
{
‘type’: ‘HorizontalLayout’,
‘elements’: [
{
‘type’: ‘Control’,
‘label’: {
‘text’: ‘Name’,
‘show’: true
},
‘scope’: {
‘$ref’: ‘#/properties/name’
}
},
{
‘type’: ‘Control’,
‘label’: {
‘text’: ‘Age’
},
‘scope’: {
‘$ref’: ‘#/properties/personalData/properties/age’
}
},
{
‘type’: ‘Control’,
‘label’: ‘Height’,
‘scope’: {
‘$ref’: ‘#/properties/personalData/properties/height’
}
}
]
},
{
‘type’: ‘HorizontalLayout’,
‘elements’: [
{
‘type’: ‘Control’,
‘label’: ‘Nationality’,
‘scope’: {
‘$ref’: ‘#/properties/nationality’
}
},
{
‘type’: ‘Control’,
‘label’: ‘Occupation’,
‘scope’: {
‘$ref’: ‘#/properties/occupation’
},
‘suggestion’: [‘Accountant’, ‘Engineer’, ‘Freelancer’,
‘Journalism’, ‘Physician’, ‘Student’, ‘Teacher’, ‘Other’]
},
{
‘type’: ‘Control’,
‘label’: ‘Birthday’,
‘scope’: {
‘$ref’: ‘#/properties/birthDate’
}
}
]
},
{
‘type’: ‘Control’,
‘label’: ‘list’,
‘scope’: {
‘$ref’: ‘#/properties/investments’
}
}
]
};
private data = {
name: ‘John Doe’,
birthDate: ‘1985-06-02’,
investments : [
{ make: ‘Toyota’, model: ‘Celica’, price: 35000 },
{ make: ‘Ford’, model: ‘Mondeo’, price: 32000 },
{ make: ‘Porsche’, model: ‘Boxter’, price: 72000 }
]
};
Edited
1:27pm
I have imported as-grid: npm install --save ag-grid-community ag-grid-angular
1:30pm
schema= { ‘investments’: {
‘type’: ‘object’,
‘properties’: {
‘type’: ‘grid’,
‘className’: ‘ag-theme-balham’,
‘templateOptions’: {
‘height’: ‘200px’,
‘class’: ‘ag-fresh’,
‘gridOptions’: {
‘rowHeight’: 42,
‘paginationPageSize’: 15,
‘pagination’: true,
‘columnDefs’: [
{‘headerName’: ‘User Group’, ‘field’: ‘group’, ‘sortable’: true, ‘filter’: true, ‘checkboxSelection’: true },
{‘headerName’: ‘Role’, ‘field’: ‘role’, ‘sortable’: true, ‘filter’: true},
{‘headerName’: ‘Status’, ‘field’: ‘status’, ‘sortable’: true, ‘filter’: true }
],
},
}
}
}
};
1:33pm
private uischema = {
‘type’: ‘VerticalLayout’,
‘elements’: [
{
{
‘type’: ‘Control’,
‘label’: ‘list’,
‘scope’: {
‘$ref’: ‘#/properties/investments’
}
}
]
};
1:36pm
How do i register ag-grid and define controls so that i can render?
<ag-grid-angular #agGrid style=“width: 100%; height: 100%;”
class=“ag-theme-balham”
[rowData]=“rowData | async”
[columnDefs]=“columnDefs”
rowSelection=“multiple”>