我创建了一个从json数据中读取url的kendo网格。下面是代码,它工作正常ajax调用后重新加载kendo网格
$('#grid').kendoGrid({
dataSource: {
transport: {
read: {
url: "http://localhost/CoreProcess/proceso/getusers",
dataType: "json",
},
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"}],
});
现在在同一页面,我有一点点的形式,通过Ajax调用插入新的数据到数据库中的PHP方法(IM与Yii框架工作)
$.ajax({
type: "POST",
url: "http://localhost/CoreProcess/proceso/agregarparticipantes/uuid/" + uuid,
data:
{
post_participante: participante,
post_apellidos: apellidos,
post_email: email,
},
success: function(result)
{
alert(result);
var dSource = $('#grid').data('kendoGrid').dataSource;
dSource.transport.options.read.url = "http://localhost/CoreProcess/proceso/getusers";
dSource.read();
}
});
在数据库中创建一个新记录也可以正常工作,但问题是之后我想用新信息重新加载网格,或许再次阅读我应该更改的json url。我尝试了很多东西,比如
$('#grid').data('kendoGrid').dataSource.read();
$('#grid').data('kendoGrid').dataSource.refresh();
但是没什么,我是用剑道的noob ...任何人都可以帮我吗?谢谢所有
您不需要再次设置URL。 ('#grid')。data('kendoGrid')。dataSource.read();应该管用。你确定数据库中插入了新行吗? – 2014-10-20 05:44:35
是的确定如果我再次加载网站的新行出现在网格中。感谢您的帮助 – sklapez 2014-10-20 13:17:38