function games(){
$result = $this->DB1->select('id,name')->get('game');
echo '{"data":'.json_encode($result->result()).'}';
}
var libStore = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : 'VersionMgr/games'
}),
reader : new Ext.data.JsonReader({
root : "data"
}, [{name : "id"},
{name : "name"}])
});
// libStore = [['90','HUG'],['78','test']];
var libCombo = new Ext.form.ComboBox({
store : libStore,
emptyText : "请选择名称",
editable : false,
id : "game",
fieldLabel : "业务名称",
displayField : "name",
valueField : "id",
value : "",
width : 200,
triggerAction : "all",
allowBlank:false,
// mode : "local"
});
//编码选择
var encoding = new Ext.form.ComboBox({
store : [['GBK','GBK'],['UTF-8','UTF-8'],['GB2312','GB2312'],['UTF-16','UTF-16'],['windows-1252','windows-1252'],['ISO-8859-1','ISO-8859-1']],
emptyText : "请选择编码 ",
editable : false,
id : "encoding",
fieldLabel : "版本编码",
value : "",
width : 200,
triggerAction : "all",
allowBlank:false,
mode : "local"
});
var version_postWindow = new Ext.Window({
title: '版本生成',
width: 400,
height:200,
collapsible:true,
maximizable:true,
bodyStyle:'padding:5px 25px 0',
plain:true,
modal:true,
defaultType: 'textfield',
items: [{
xtype : 'form',
id:'version',
baseCls:"x-plain",
defaultType: 'textfield',
items:[
libCombo
,encoding
,{
fieldLabel: '版本号',
id: 'version_show',
regex : /^[0-9]+$/,
regexText:"只能输入数字!",
allowBlank : false,
sideText : '<font color=red>*如:20120328</font>'
},{
fieldLabel: '加密',
xtype : 'checkbox',
id: 'encryption'
}, {
fieldLabel: '支持URL编码',
labelSeparator: '',
xtype : 'checkbox',
id: 'urlencode'
}]
}],
buttons: [{
text: '生成',
handler: function(){
var panel = version_postWindow.findById('version');
var form = panel.getForm();
if(form.isValid()){
console.log(form.getFieldValues());//取得列值
// console.log(form.getValues());//取得文本值
}
}
},{
text: '关闭',
handler:function(){
version_postWindow.close();
}
}]
});
version_postWindow.show(this);
=========================
buttons: [{
text: '生成',
handler: function(){
console.log(this);
var panel = version_postWindow.findByType('form')[0];
var form = panel.getForm();
if(form.isValid()){
console.log(form.getValues());
}
//获取表单中某个控件的值
// this.getForm().findField('id').getValue()
//获取表单中所有控件的值
// console.log(this.getForm().getValues());
}
},{
text: '关闭',
handler:function(){
version_postWindow.close();
}
}]
});
=========================
var version_form = new Ext.form.FormPanel({
plain:true,
layout:"form",
labelWidth:80,
baseCls:"x-plain",
frame : true,
bodyStyle:'padding:5px 25px 0',
defaultType: 'textfield',
items: [libCombo
,encoding
,{
fieldLabel: '版本号',
name: 'version_show',
regex : /^[0-9]+$/,
regexText:"只能输入数字!",
allowBlank : false,
sideText : '<font color=red>*如:20120328</font>'
},{
fieldLabel: '加密',
xtype : 'checkbox',
name: 'encryption'
}, {
fieldLabel: '支持URL编码',
labelSeparator: '',
xtype : 'checkbox',
name: 'urlencode'
}
]
});
==============
{
fieldLabel: 'First Name',
name: 'first',
regex : /[\u4e00-\u9fa5]/, //正则表达式在/...../之间. [\u4e00-\u9fa5] : 只能输入中文.
regexText:"只能输入中文!", //正则表达式错误提示
allowBlank : false //此验证依然有效.不许为空.
}, new Ext.form.ComboBox({
transform:"encoding",//html中的id
width:80,//宽度
height:150
})
==================
Ext学习系列(9)-- Ext.data.HttpProxy
(2010-03-23 14:32:08)httpProxy是从object继承来的,事实上source中它和下面的Ext.data.MemoryProxy/Ext.data.ScriptTagProxy都继承于DataProxy
HttpProxy用于远程代理,而且服务端返回信息时必须指定Content-Type属性为"text/xml".
HttpProxy( Object conn )
构造一个HttpProxy对象,参数可以是一个类似于{url: 'foo.php'}这样的json对象,也可以是一个Ext.data.Connection对象,如果参数没有指定,将使用Ext.Ajax对象将被用于发起请求
getConnection() : Connection
得到当前连接对象
load( Object params, Ext.data.DataReader reader, Function callback, Object scope, Object arg ) : void
从配置的connection对象得到record数据块,并激发callback
params: 发起http请求时所要传递到服务端的参数
DataReader: 见DataReader
callback: 回叫方法,第一个参数为接收到的信息,第二个参数为arg,第三个是成功标志
scope: 范围
arg: 这儿的参数将会传递给回叫函数callback
例:
JS代码:
Ext.onReady(function() {
//数据
var proxy1 = new Ext.data.HttpProxy({ url: "ExtData/Ext_Info3.aspx" });
var reader1 = new Ext.data.JsonReader({
root: "data",
id: "id",
totalProperty: "totalCount",
successProperty: "success"
},
[
{ name: "id", mapping: "id" },
{ name: "name", mapping: "name" },
{ name: "sex", mapping: "sex" }
]