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:
{
"data": [
{
"id": "_generatedModelClass_6f71edf1-9755-42b9-ab7f-a035f385fdca",
"name": "Han"
},
{
"id": "_generatedModelClass_0c7840d3-995f-4b6f-a664-d3ab05352395",
"name": "Leia"
}
]
}
{
"data": [
{
"id": 1,
"name": "Han"
},
{
"id": 2,
"name": "Leia"
}
]
}
The server is expected to respond with the same records as the request and to include any new fields created on the server (such as the server-generated id).
Update records
Records are updated in the same way that they are created (using createUrl), but a POST request is made to updateUrl:
{
"data": [
{ "name": "Kylo", "id": 1 },
{ "name": "Rey", "id": 2 }
]
}
{
"data": [
{
"id": 1,
"name": "Kylo"
},
{
"id": 2,
"name": "Rey"
}
]
}
Remove records
Records are removed using the simplest structure: A POST call is made to deleteUrl.
{ "ids": [1, 2] }
success property:
{
"success" : true
}
To read more, visit the guide to using AjaxStore.