繁体   English   中英

Ajax调用后重新加载Kendo Grid

[英]Reloading Kendo Grid after ajax call

我创建了一个Kendo网格,该网格从具有json数据的url中读取。 这是代码,它可以正常工作

$('#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"}],          
});

现在在同一页面中,我有一个小表格,可通过对php方法的ajax调用将新数据插入数据库(即与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();

但是什么都没有,我对剑道不是菜鸟...有人可以帮助我吗? 谢谢大家

最终我得到了解决,与剑道一无所获。 我使用的是Yii框架,在数据库中保存记录后,您必须刷新它,以便可以加载新信息,这是一个简单的错误,但是我对Kendo的了解如何,我不知道这是对还是错。

简单说明

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

对我来说足够了

谢谢大家的支持,我将继续使用这个出色的工具。 下一步看问题xD

在dataSource读取设置中,您已经有了默认的HTTP方法'GET',并且它正在缓存查询数据。 解决方法一:

read: {
    url: "http://localhost/CoreProcess/proceso/getusers",
    dataType: "json",
    type: "POST",
},

解决方案二:

read: {
    url: "http://localhost/CoreProcess/proceso/getusers",
    dataType: "json",
    cache: false,
},

然后只需使用dataSource.read()方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM