I got some problem with jsgrid while loading some data (failed to load data)
here is my code
Client:
<script>
$(function() {
$("#jsGrid").jsGrid({
height: "50%",
width: "100%",
filtering: true,
inserting: true,
editing: true,
sorting: true,
paging: true,
autoload: true,
pageSize: 10,
pageButtonCount: 5,
deleteConfirm: "Do you really want to delete client?",
controller: {
loadData: function (filter) {
var d = $.Deferred();
$.ajax({
type: "POST",
url: '@Url.Action("Category", "Management")' + '?method=' + 'GET',
data: filter,
contentType: 'application/json; charset=utf-8',
dataType: "json"
}).done(function (response) {
d.resolve(response.value);
});
return d.promise();
}
},
fields: [
{ name: "Categoria", type: "text", width: 150 },
{ name: "Id", type: "number", width: 50 },
{ name: "Nome", type: "text", width: 150 },
{ name: "Valor", type: "number", width: 200 },
{ type: "control" }
]
});
});
</script>
Server:
[HttpPost]
public IActionResult Category(string method, [FromBody] Product filter)
{
if(method.ToUpper() == "GET")
{
var aa = productRepository.GetProducts.ToList();
return StatusCode(200, aa);
}
else
{
return null;
}
}
Here is my debugging result enter image description here
successfully loaded data! but, blow this code,
d.resolve(response.value);
non-value exist in response.value.. how can I add or create it?
jsgrid homepage said
loadData is a function returning an array of data or jQuery promise that will be resolved with an array of data (when pageLoading is true instead of object the structure { data: [items], itemsCount: [total items count] } should be returned). Accepts filter parameter including current filter options and paging parameters when pageLoading is true.
I don't know how to solve this problem.
I think I got some problem in backend code
please help me.
thank you.
try
in the method. Probably you don't return a Json object.