本文目录一览:
- 1、EXT 的问题,把JsonStore里的数据显示到FormPanel里
- 2、Extjs中我用data.jsonStore从后台获取数据后.前台再往里面添加一条数据.
- 3、EXT 中 一个页面中 2个Store 互相传值
- 4、Ext问题,我找了好久也没解决,希望您能帮我一下。
EXT 的问题,把JsonStore里的数据显示到FormPanel里
你可以用formpanel的load事件,load成功的话,会按照formpanel上控件的name属性,自动赋值上去
官方的例子:
var myFormPanel = new Ext.form.FormPanel({
title: ‘Client and routing info’,
items: [{
fieldLabel: ‘Client’,
name: ‘clientName’
}, {
fieldLabel: ‘Port of loading’,
name: ‘portOfLoading’
}, {
fieldLabel: ‘Port of discharge’,
name: ‘portOfDischarge’
}]
});
myFormPanel.getForm().load({
url: ‘/getRoutingInfo.php’,
params: {
consignmentRef: myConsignmentRef
},
failure: function(form, action) {
Ext.Msg.alert(“Load failed”, action.result.errorMessage);
}
});
//成功返回时的json例子
{
success: true, //告诉formpanel取值成功
data: { //数据
clientName: “Fred. Olsen Lines”,
portOfLoading: “FXT”,
portOfDischarge: “OSL”
}
}
Extjs中我用data.jsonStore从后台获取数据后.前台再往里面添加一条数据.
//定义类型,注意和你json返回的记录格式要一致
var MyRecordType = Ext.data.Record.create
([
{name: “id”, type: “int”},
{name: “name”, type: “string”}
]);
//要添加的记录
var oneRecord = new RecordType
({
id: 0,
name: “张三”
});
//Store
var userStore = new Ext.data.Store({
//此处省略
})
userStore.load();
userStore.add(oneRecord);
EXT 中 一个页面中 2个Store 互相传值
其实不用这样
你的store里面的proxy直接用Ext.data.MemoryProxy
不要用Ext.data.HttpProxy
当你想要读取数据的时候
直接用Ext.Ajax.request去后台读取
返回数据解析后
隔半秒调用一下方法添加一条数据
全部例子如下:
var store = new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(),
reader: new Ext.data.JsonReader({
id: ‘id’
},
[
{ name: ‘id’ },
{ name: ‘name’ }
])
});
new Ext.grid.GridPanel({
store: store,
columns: [{ header: “id”, dataIndex: ‘id’ }, { header: “name”, dataIndex: ‘name’}]
});
Ext.Ajax.request({
url: “”,
success: function (response) {
var data = Ext.util.JSON.decode(response.responseText);
setTime(loadDate, 500, data);
}
});
//重写定时函数
function setTime(callback, timeout, param) {
var args = Array.prototype.slice.call(arguments, 2);
var _cb = function () {
callback.apply(null, args);
}
__sto(_cb, timeout);
}
//添加数据
function loadDate(data) {
store.add(new store.recordType(data.shift()));
if (data.length 0) {
setTime(arguments.callee, 500, data);
}
}
Ext问题,我找了好久也没解决,希望您能帮我一下。
在store的reload()方法中使用 baseParams 吧,刚开始传一个-1或者什么的,服务端当特例处理一下,有查询条件时,将条件通过baseParams传递,应该就不会丢了,即使pagingBar翻页也应该不会丢的。
baseParams : Object
每次HTTP请求都会带上这个参数,本来它是一个对象的形式,请求时会转化为参数的字符串。
原创文章,作者:小蓝,如若转载,请注明出处:https://www.506064.com/n/192568.html