導航:首頁 > 編程語言 > extjsphp實例

extjsphp實例

發布時間:2022-09-11 23:20:59

1. 怎麼運用extjs mvc 與thinkphp實現省市區三級聯動

開始自動讀省數據,選擇省讀市數據,選擇市讀區數據。
有點小BUG:第二次選省時,讀市有問題。。。
JS:

[javascript] view plain
Ext.require('Ext.*');
Ext.onReady(function () {
//定義ComboBox模型
Ext.define('State', {
extend: 'Ext.data.Model',
fields: [
{ type: 'int', name: 'id' },
{ type: 'string', name: 'cname' }
]
});
// debugger
//載入省數據源
var store = Ext.create('Ext.data.Store', {
model: 'State',
proxy: {
type: 'ajax',
url: 'GetTest2Data?strAct=sheng'
},
autoLoad: true,
remoteSort: true
});
//載入市數據源
var store1 = Ext.create('Ext.data.Store', {
model: 'State',
proxy: {
type: 'ajax',
url: 'GetTest2Data?strAct=shi'
},
autoLoad: false,
remoteSort: true
});
//載入區數據源
var store2 = Ext.create('Ext.data.Store', {
model: 'State',
proxy: {
type: 'ajax',
url: 'GetTest2Data?strAct=qu'
},
autoLoad: false,
remoteSort: true
});
Ext.create("Ext.panel.Panel", {
renderTo: document.body,
width: 290,
height: 220,
title: "城市三級聯動",
plain: true,
margin: '30 10 0 80',
bodyStyle: "padding: 45px 15px 15px 15px;",
defaults: {
autoScroll: true,
bodyPadding: 10
},
items: [{
xtype: "combo",
name: 'sheng',
id: 'sheng',
fieldLabel: '選擇省',
displayField: 'cname',
valueField: 'id',
store: store,
triggerAction: 'all',
queryMode: 'local',
selectOnFocus: true,
forceSelection: true,
allowBlank: false,
editable: true,
emptyText: '請選擇省',
blankText: '請選擇省',
listeners: {
select: function (combo, record, index) {
try {
//userAdd = record.data.name;
var parent = Ext.getCmp('shi');
var parent1 = Ext.getCmp("qu");
parent.clearValue();
parent1.clearValue();
parent.store.load({ params: { strParam: this.value} });
}
catch (ex) {
Ext.MessageBox.alert("錯誤", "數據載入失敗。");
}
}
}
},
{
xtype: "combo",
name: 'shi',
id: 'shi',
fieldLabel: '選擇市',
displayField: 'cname',
valueField: 'id',
store: store1,
triggerAction: 'all',
queryMode: 'local',
selectOnFocus: true,
forceSelection: true,
allowBlank: false,
editable: true,
emptyText: '請選擇市',
blankText: '請選擇市',
listeners: {
select: function (combo, record, index) {
try {
//userAdd = record.data.name;
var parent = Ext.getCmp("qu");
parent.clearValue();
parent.store.load({ params: { strParam: this.value} });
}
catch (ex) {
Ext.MessageBox.alert("錯誤", "數據載入失敗。");
}
}
}
},
{
xtype: "combo",
name: 'qu',
id: 'qu',
fieldLabel: '選擇區',
displayField: 'cname',
valueField: 'id',
store: store2,
triggerAction: 'all',
queryMode: 'local',
selectOnFocus: true,
forceSelection: true,
allowBlank: false,
editable: true,
emptyText: '請選擇區',
blankText: '請選擇區'
}
]
});
});

Controllers里代碼:

[csharp] view plain
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult GetTest2Data(string strAct, string strParam)
{
//string strAct = Request["act"];
//string strParam = Request["param"];
List<Test2Model> listModel = new List<Test2Model>();

#region MyRegion
if (strAct == "sheng")
{
listModel.Add(new Test2Model() { cname = "北京市", id = 110000 });
listModel.Add(new Test2Model() { cname = "內蒙古自治區", id = 150000 });
}
if (strAct == "shi")
{
if (strParam == "110000")
{
listModel.Add(new Test2Model() { cname = "市轄區", id = 110100 });
listModel.Add(new Test2Model() { cname = "市轄縣", id = 110200 });
}
else if (strParam == "150000")
{
listModel.Add(new Test2Model() { cname = "呼和浩特市", id = 150100 });
listModel.Add(new Test2Model() { cname = "包頭市", id = 150200 });
}

}
if (strAct == "qu")
{
if (strParam == "110100")
{
listModel.Add(new Test2Model() { cname = "朝陽區", id = 110101 });
listModel.Add(new Test2Model() { cname = "昌平區", id = 110102 });
}
else if (strParam == "110200")
{
listModel.Add(new Test2Model() { cname = "密雲縣", id = 110201 });
listModel.Add(new Test2Model() { cname = "房山縣", id = 110202 });
}
else if (strParam == "150100")
{
listModel.Add(new Test2Model() { cname = "回民區", id = 150101 });
listModel.Add(new Test2Model() { cname = "新城區", id = 150102 });
}
else if (strParam == "150200")
{
listModel.Add(new Test2Model() { cname = "青山區", id = 150201 });
listModel.Add(new Test2Model() { cname = "東河區", id = 150202 });
}
}
#endregion

return Json(listModel, JsonRequestBehavior.AllowGet);
}

Models代碼:

[csharp] view plain
public class Test2Model
{
public string cname { get; set; }
public int id { get; set; }
}

2. extjs的example怎麼使用

1、首先,把example放到你項目的extjs目錄下部署起來。
2、然後通過伺服器url+/example訪問。
3、部分example代碼是用php寫的,可能需要相應的應用伺服器,不過大多數都可以使用的

3. extjs文件中如何調用php

//比如用AJAX
Ext.Ajax.request({
url:"xxx.php",
callback:function(opt,succ,res){
....
}
})

4. extjs里,php生成的驗證碼怎麼點擊圖片就刷新

給那個圖片的panel加上一個監聽事件listeners:{ 'click':function(){}}

5. extjs自帶例子怎麼用

Ext裡面自帶的例子一般都是數據已預先設定好的。
你可以參考例子的數據定義格式,自己定義一套數據。
例如你說的calendar,它的數據定義在calendar/data/Events.js文件中,你仔細看看就能明白了

閱讀全文

與extjsphp實例相關的資料

熱點內容
編譯動態庫時會連接依賴庫嗎 瀏覽:706
淘寶手機加密是隨機的嗎 瀏覽:672
解壓包子怎麼裝飾 瀏覽:585
四個數湊24演算法 瀏覽:676
哪一種不是vi編譯器的模式 瀏覽:168
xp在此處打開命令窗口 瀏覽:128
代碼編譯運行用什麼軟體 瀏覽:997
動態庫在程序編譯時會被連接到 瀏覽:760
python超簡單編程 瀏覽:259
獲取命令方 瀏覽:976
怎樣製作文件夾和圖片 瀏覽:58
調研編譯寫信息 瀏覽:861
python馮諾依曼 瀏覽:419
同時安裝多個app有什麼影響 瀏覽:254
奧術殺戮命令宏 瀏覽:184
用sdes加密明文字母e 瀏覽:361
單片機原理及應用試題 瀏覽:425
易語言開啟指定文件夾 瀏覽:40
馬思純參加密室大逃脫 瀏覽:322
文件夾冬季澆築溫度 瀏覽:712