標籤:des style http java color 使用
Ext.onReady(function{
var jj_form = new Ext.FormPanel({
url : ‘jj_form_submit.java‘,
renderTo : document.body,
frame : true,
title : ‘formtest_jj‘,
width : 250,
items : [{
xtype : ‘textfield‘,
fieldlabel : ‘username‘,
name : ‘username‘
},{
xtype : ‘textfield‘,
fieldlabel : ‘password‘,
name " ‘password‘
},{
xtype : ‘datafield‘,
fieldlabel : ‘data‘,
name : data
}
]
});
});
這個實際上就是一個表單對象,其中xtype表示的是表單控制項的類型,類型有:textfield,timefield,datafield,numberfield,combo,textarea.
表單校正功能:
allowBlank : false ;不允許空。
disabledDays : [1,2,3,4,5] 不允許選擇星期一,二,三,四,五。一定要記得0代表Sunday
其實vtype這種內建校正也是可以進行檢驗的,比如:vtype : ‘alpha‘ 則表示輸入只能匹配文字字元,還有許多其他的約束條件,可以通過論壇中尋找擷取到。
顯示錯誤的方式:
Ext.onReady(function(){
Ext.QuickTips.init() //通常是放在第一行,通過一個氣球來提示錯誤資訊
});
自訂檢驗,設定自己的vtype:
Ext.form.VTypes[‘nameVal‘] = /^[A-Z][A-Za-z\-] + [A-Z][A-Za-z\-] + $/;
Ext.form.VTypes[‘nameMask‘] = /[A-Za-z\-]/;
Ext.form.VTypes[‘nameText‘] = ‘Invalid name!‘;
Ext.form..VTypes[‘name‘] = function(v){
return Ext.form.VTypes[‘nameVal‘].test(v);
}
選項按鈕(radio button),複選框(check boxes)和組合框(ComboBox)
radio button : {
xtype : ‘radio‘,
fieldlabel : ‘Color‘.
name : ‘color‘,
boxlabel : ‘White‘
}.{
xtype : ‘radio‘,
name : ‘color‘,
hideLabel : false,
boxlabel : ‘Black‘
labelSpearator : ‘‘
}
check box : {
xtype : ‘checkbox‘,
fieldlabel : ‘Are you sure‘,
name : ‘Are you sure‘
}
comboBox :
首先要定義一個資料集合,其中data可以有很多種的形式,這裡我們選擇的是SimpleStore。
var data_store = new Ext.data.SimpleStore(){
fields : [‘id‘, ‘username‘],
name : [[1, aichengqi], [2, chenli],[3, yuguoxin]]
})
{
xtype : ‘combo‘,
fieldlabel : ‘user‘,
name : ‘user‘,
mode : ‘local‘,
store : ‘username‘,
displayfield : ‘username‘,
width : 120
}
資料庫驅動的ComboBox
這裡是用PHP語言編寫的如何擷取JSON資料的方式;(由於涉及到了PHP的函數問題,就沒有過多研究了)
之後我們使用JSON Reader來實現遠端資料的功能;
var remote_data = new Ext.data.Store({
reader : new Ext.data.JsonReader({
fields : [id, username],
root : ‘rows‘
}),
proxy : new Ext.data.HttpProxy({
url : data/username.php
}),
autoLoad : true
});
remote_data.load();
文本域(TextArea)和html編輯器(html Editor)
TextArea :
{
xtype : ‘textarea‘,
fieldlabel : ‘comment‘,
name : ‘commment‘,
labelSeparator : ‘‘,
hideLabel : true,
height : 100,
anchor : ‘100%‘
}
html Dditor 和上面的一樣 :
{
xtype : ‘htmleditor‘,
fieldlabel : ‘editor‘,
name : ‘editor‘,
hideLabel : true,
labelSeparator,
height : 100,
anchor : ‘100%‘
}