Understanding structure
Understanding the structure of the request and response bodies is vital to working smoothly with data. The structure of requests and responses varies depending on the type of request, the changes made, and how the request is made.
Bryntum Grid doesn't use any additional stores. We only use AjaxStore, which makes things straightforward.
AjaxStore request and response structure
The data in an AjaxStore is structured based on the request type or operation.
Read records
When using readUrl, the response structure is expected in one of the following formats.
The response can be an array of data:
[
{ "id" : 1, "name" : "Han" },
{ "id" : 2, "name" : "Luke" }
]
Alternatively, the response can be an object with the following format:
{
"success" : true,
"data" : [
{ "id" : 1, "name" : "Leia" },
{ "id" : 2, "name" : "Lando" }
]
}
Create records
When a createUrl endpoint is hit, the request and response are structured as follows:
The request structure looks like this:
{
"data": [
{
"id": "_generatedModelClass_6f71edf1-9755-42b9-ab7f-a035f385fdca",
"name": "Han"
},
{
"id": "_generatedModelClass_0c7840d3-995f-4b6f-a664-d3ab05352395",
"name": "Leia"
}
]
}
Update records
Records are updated in the same way that they are created (using createUrl),
but a POST request is made to updateUrl:
The request structure is as follows:
{
"data": [
{ "name": "Kylo", "id": 1 },
{ "name": "Rey", "id": 2 }
]
}
Remove records
Records are removed using the simplest structure: A POST call is made to deleteUrl.
The request includes only the IDs of the deleted records:
{ "ids": [1, 2] }
To read more, visit the guide to using AjaxStore.