[英]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.