gpt4 book ai didi

php - ExtJS 在 Ajax 返回 (json) 上加载数据并为 grid.panel 加载存储

转载 作者:行者123 更新时间:2023-12-01 04:10:30 25 4
gpt4 key购买 nike

下面的代码正常工作加载数据MyData变量,但需要获取来自php页面的数据,然后单击存储馈送网格。在我的php页面中,它生成一个代码json,然后ajax将其保存在变量数据中,在警报(javascript)中它显示信息。

从现在开始,谢谢;

    pdvs : function () {

$(document).ready(function () {
$.ajax({
url : "relpontovendaper.php",
dataType : "json",
success : function (data) {
alert(data[1].nome);
}
});
});

// return php [ { "nome": "Claudemir", "sobrenome": "Feliciano" }, { "nome": "Mario Borges" , "sobrenome": "Juno" } ]

var store = new Ext.data.JsonStore({
fields : ['name', 'area']
});

//This is Load.
var myData = [['Maria', 'santos'],
['Lucas', 'pereira'],
['Mariana', 'fagundes']];

var store = new Ext.data.SimpleStore({
fields : [
'nome',
'sobrenome'
]
});

// this load in grid
store.loadData(myData);

//this dont load in grid - informations of ajax in format json
store.loadData(data);

Ext.getCmp("_relpontoperiodo_grid").getStore().loadData(myData);

}
//This is a item (window)
items : [{
xtype : "grid",
id : "_relpontoperiodo_grid",
height : 230,
width : 200,
store : new Ext.data.SimpleStore({
fields : [
'nome',
'sobrenome'
]
}),
columns : [{
header : "PDV_COD",
sortable : true,
dataIndex : 'nome'
}, {
header : "PDV_DESCRIÇÃO",
sortable : true,
dataIndex : 'sobrenome',
flex : 1
}
]
}
]

最佳答案

要远程检索数据(在本例中是从php),您可以向商店添加代理。这是一个例子:

var store = new Ext.data.JsonStore({
fields : ['name', 'area'],
autoLoad:true, //this will autoLoad the store on load. Or you can call
//store.load() later.
proxy: {
type: 'ajax',
url: 'relpontovendaper.php',
reader: {
type: 'json',
root: ''
}
}
});

More info is available on sencha docs.

关于php - ExtJS 在 Ajax 返回 (json) 上加载数据并为 grid.panel 加载存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21268055/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com