This is a migrated thread and some comments may be shown as answers.

Reloading Kendo Grid after ajax call

2 Answers 1308 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Antonio
Top achievements
Rank 1
Antonio asked on 20 Oct 2014, 02:09 PM
I have created a kendo grid that reads from a url with json data. Here is the code and it works ok

$('#grid').kendoGrid({
dataSource: {
transport: {
read: {
url: "http://localhost/CoreProcess/proceso/getusers",
dataType: "json",
cache: false
},
update: {
url: "http://localhost/CoreProcess/usuario/uptdate",
dataType: "json"
},
destroy: {
url: "http://localhost/CoreProcess/usuario/delete",
dataType: "json"
}
},
pageSize: 10
},
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
editable: "inline",
columns: [{ title: "Nombre", field: "NOMBRE" },
{ title: "Apellidos", field: "APELLIDOS"},
{ title: "Email", field: "EMAIL"},
{ command: ["edit", "destroy"], title: "Acciones"}],
});

Now in the same page i have a little form that inserts new data to the database through an ajax call to a php method (im working with yii framework)

$.ajax({
type: "POST",
url: "http://localhost/CoreProcess/proceso/agregarparticipantes/uuid/" + uuid,
data:
{
post_participante: participante,
post_apellidos: apellidos,
post_email: email,
},
success: function(result)
{
$('#grid').data('kendoGrid').dataSource.read();
}
});

The creation of a new record in the database also works fine but the problem is that after that i want to reload the grid with the new information, perhaps reading again the json url that i should have changed. I have tried a lot of things like

$('#grid').data('kendoGrid').dataSource.read();
$('#grid').data('kendoGrid').dataSource.refresh();

But nothing, i am noob with kendo...anyone could help me? thanks all

2 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 22 Oct 2014, 08:04 AM
Hello Antonio,

Indeed, calling DataSource read will issue request to the server and automatically refresh the Grid content. However, looking at the code snippet you have pasted it is not obvious what may causing the Grid not refreshing. Could you please verify that the $.ajax success function is actually executed?

If you continue experiencing difficulties please provide a small runnable sample in which the issue can be observed locally.

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Antonio
Top achievements
Rank 1
answered on 24 Oct 2014, 10:25 AM
Hi Rosen

Thanks for the help, finally I got fix it and It had not anything to see with Kendo. Im using Yii framework and after save records in the database you have to refresh it so the new information could be loaded, a simple error but how Im new with Kendo I did not know if I was doing it wrong or right.

Thanks for the support I will continue using this fantastic tool. See in nexts problems xD
Tags
Grid
Asked by
Antonio
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Antonio
Top achievements
Rank 1
Share this question
or