Comment lier la grille de l'interface utilisateur Kendo à une API GraphQL
var dataSource = nouveau kendo.data.DataSource ({
pageSize: 20,
transport: {
[19659011] read: {
contentType: "application / json"
type: "POST"
données: function () {
return {query: READ_PRODUCTS_QUERY};
}
},
update: {
contentType: "application / json"
type: "POST"
data: function (modèle) {
return {
requête: UPDATE_PRODUCT_QUERY,
variables: model
[19659053]};
}
},
destroy: {
contentType: "application / json"
] type: "POST"
data: function (modèle) {
return {
[19659049] requête: DELETE_PRODUCT_QUERY, [19659006] variables: modèle
};
}
},
create: {
contentType: ] "application / json"
type: "POST"
data: function (modèle) {
return {
requête: ADD_PRODUCT_QUERY,
variables: modèle
};
}
}, [19659006] parameterMap: function (options, operation) {
return kendo.stringify (options);
}
},
schéma: {
data: function (réponse) {
var data = response.data; 19659006]
(data.products) {
retourner data.products;
} else si (data.AddProduct) {
retourner data.AddProduct;
} sinon si (data.UpdateProduct) {
return data.UpdateProduct;
else if (data.DeleteProduct) {
return data.DeleteProduct;
}
},
modèle: {
id: "ProductID"
champs: {
ProductID: {type: "string" modifiable: false },
ProductName: { type: "string" },
UnitPrice: {type: "number" },
UnitsInStock: {type: "number" }
}
}
}) [19659201]
Source link
