麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 編程 > JavaScript > 正文

Extjs單獨(dú)定義各組件的實(shí)例代碼

2019-11-20 22:36:53
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
網(wǎng)上看到的一個(gè)事例,其中包含了組件的定義拷貝下來(lái)供大家參考:
復(fù)制代碼 代碼如下:

Ext.onReady(function(){
var dtCategory=[
['all','所有種類'],
['1','Beverages'],
['2','Condiments'],
['3','Confections'],
['4','Dairy Products'],
['5','Grains/Cereals'],
['6','Meat/Poultry '],
['7','Produce'],
['8','Seafood']
];
var stCategory=new Ext.data.SimpleStore({
fields:['value','text'],
data:dtCategory
});
var cbCategory=new Ext.form.ComboBox({
id:"cbCategory",
store:stCategory,
displayField:"text",
valueField:"value",
typeAhead:true,
mode:"local",
triggerAction:"all",
emptyText:"請(qǐng)選擇商品種類...",
editable:false,
allowBlank:false,
blankText:"商品種類必須選擇",
autoSelect:true,
selectOnFoucus:true,
value:'',
dfval:''
});
cbCategory.setValue("all");
var tfName=new Ext.form.TextField({
id:'tfName'
});
var btnSearch=new Ext.Button({
id:'btnSearch',
iconCls:'btn_search',
text:'搜索',
handler:function(){
stProduct.load({params:{start:0,limit:10,categoryName:Ext.getCmp("cbCategory").getValue(),productName:Ext.getCmp("tfName").getValue()}});
}
});
var btnHelp=new Ext.Button({
text:'幫助',
iconCls:'btn_help'
})
var tb=new Ext.Toolbar({
id:'tb',
items:[
'商品種類:',
cbCategory,
'-',
'商品名稱:',
tfName,
btnSearch,
'->',
btnHelp
]
});
var pnNorth=new Ext.Panel({
id:'pnNorth',
region:'north',
autoHeight:true,
items:[
tb
]
});
var url="Default.aspx";
var stProduct=new Ext.data.Store({
id:"st",
proxy:new Ext.data.HttpProxy({url:url}),
reader:new Ext.data.JsonReader({totalProperty:"totalProperty",root:"root",fields:[{name:"ProductID"},{name:"ProductName"},{name:"CategoryName"},{name:'UnitPrice'},{name:'Discontinued'},{name:'QuantityPerUnit'},{name:'CompanyName'}] })//ProductID作為隱藏列,不顯示在gridpanel中
});
stProduct.load({params:{start:0,limit:10,categoryName:Ext.getCmp("cbCategory").getValue(),productName:Ext.getCmp("tfName").getValue()}});
var cmProduct=new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
{header:"產(chǎn)品名稱",dataIndex:"ProductName",sortable:true},
{header:"產(chǎn)品種類",dataIndex:"CategoryName",sortable:true},
{header:"單價(jià)",dataIndex:"UnitPrice",sortable:true},
{header:"是否停產(chǎn)",dataIndex:"Discontinued",sortable:true},
{header:"規(guī)格",dataIndex:"QuantityPerUnit",sortable:true},
{header:"供貨商",dataIndex:"CompanyName",sortable:true}
]);
var pgtbProduct=new Ext.PagingToolbar({
id:"pgtbProduct",
displayInfo:true,
emptyMsg:"沒(méi)有數(shù)據(jù)要顯示!",
displayMsg:"當(dāng)前為第{0}--{1}條,共{2}條數(shù)據(jù)",
store:stProduct,
pageSize:10
});
var grdProduct=new Ext.grid.GridPanel({
id:"grdProduct",
title:"商品信息",
cm:cmProduct,
store:stProduct,
autoWidth:true,
selModel:new Ext.grid.RowSelectionModel({single:true}),
height: screen.availHeight-190,
frame: true,
pageSize:20,
bbar:pgtbProduct,
//autoExpandColumn:6,
loadMask:true,
viewConfig:{
forceFit:true
}
});
var stSupplier = new Ext.data.Store({
id: "stSupplier",
autoLoad:true,
proxy: new Ext.data.HttpProxy({ url: "ProductInfo.aspx?type=getSupplierInfo" }),
reader: new Ext.data.JsonReader({ totalProperty: "totalProperty", root: "root", fields: [{ name: "sID" }, { name: "cName"}] })
});
var pnProduct=new Ext.Panel({
id:'pnProduct',
title:'商品信息',
autoHeight:true,
items:[
new Ext.Panel({
id:'pnProductRowOne',
border:false,
bodyStyle:'padding-top:10px;',
layout:'column',
items:[
new Ext.Panel({
columnWidth:.5,
border:false,
layout:'form',
labelWidth:60,
labelAlign:'right',
items:[
{
xtype:'textfield',
id:'ProductName',
name:'ProductName',
fieldLabel:'商品名稱',
anchor:'95%'
}
]
}),
new Ext.Panel({
columnWidth:.25,
border:false,
layout:'form',
labelWidth:60,
labelAlign:'right',
items:[
{
xtype:'radio',
id:'DiscontinuedOneID',
//hiddenName:'Discontinued',
name:'Discontinued',
inputValue:'1',
fieldLabel:'是否停售',
boxLabel:'是',
anchor:'95%'
}
]
}),
new Ext.Panel({
columnWidth:.25,
border:false,
layout:'form',
labelWidth:60,
labelAlign:'right',
items:[
{
xtype:'radio',
id:'DiscontinuedTwoID',
//hiddenName:'Discontinued',
name:'Discontinued',
checked:true,
inputValue:'0',
boxLabel:'否',
anchor:'95%'
}
]
})
]
}),
new Ext.Panel({
id:'pnProductRowTwo',
border:false,
layout:'column',
items:[
new Ext.Panel({
columnWidth:.5,
border:false,
layout:'form',
labelWidth:60,
labelAlign:'right',
items:[
{
xtype:'textfield',
id:'QuantityPerUnit',
name:'QuantityPerUnit',
fieldLabel:'規(guī)格',
anchor:'95%'
}
]
}),
new Ext.Panel({
columnWidth:.5,
border:false,
layout:'form',
labelWidth:60,
labelAlign:'right',
items:[
{
xtype:'textfield',
id:'UnitPrice',
name:'UnitPrice',
fieldLabel:'單價(jià)',
anchor:'95%'
}
]
})
]
}),
new Ext.Panel({
id:'pnProductRowThree',
border:false,
layout:'column',
items:[
new Ext.Panel({
columnWidth:.5,
border:false,
layout:'form',
labelWidth:60,
labelAlign:'right',
items:[
{
xtype:'textfield',
id:'UnitsInStock',
name:'UnitsInStock',
fieldLabel:'庫(kù)存量',
anchor:'95%'
}
]
})
,
new Ext.Panel({
columnWidth:.5,
border:false,
layout:'form',
labelWidth:60,
labelAlign:'right',
items:[
{
xtype:'combo',
id:'CommpanyName',
//name:'CommpanyName',
hiddenName:'SupplierID',
fieldLabel:'供貨商',
displayField: 'cName',
valueField: 'sID',
mode: 'local',
typeAhead: true,
triggerAction: "all",
editable: false,
allowBlank: false,
autoSelect: true,
selectOnFoucus: true,
store: stSupplier,
anchor:'95%'
}
]
})
]
})
]
});
var pnCategory=new Ext.Panel({
id:'pnCategory',
title:'商品相關(guān)種類信息',
autoHeight:true,
items:[
new Ext.Panel({
id:'pnCategoryRowOne',
border:false,
bodyStyle:'padding-top:10px;',
layout:'column',
items:[
new Ext.Panel({
columnWidth:.5,
border:false,
layout:'form',
labelWidth:60,
labelAlign:'right',
items:[
{
xtype:'textfield',
id:'CategoryName',
name:'CategoryName',
fieldLabel:'商品種類',
anchor:'95%'
},
{
xtype:'textfield',
id:'Description',
name:'Description',
fieldLabel:'商品描述',
anchor:'95%'
},
{
xtype:'hidden',
id:'CategoryID',
name:'CategoryID',
fieldLabel:'種類編號(hào)'//這個(gè)是隱藏的
}
]
}),
new Ext.Panel({
columnWidth:.5,
border:false,
bodyStyle:'padding-left:25px;',
layout:'form',
labelWidth:60,
labelAlign:'right',
items:[
{
xtype:'box',//
id:'CategoryImage',
width:172,
height:120,
autoEl:{
tag:'image',
src:'tempFile/1.png'
}
}
]
})
]
})
]
});
var tpProduct=new Ext.TabPanel({//很多時(shí)候我們可能是一個(gè)表單放在不同的tab中,為了方便提交和加載數(shù)據(jù)可以在tabpanel最外層放一個(gè)formpanel,但是顯示就有問(wèn)題,這個(gè)時(shí)候可以通過(guò)設(shè)置tabpanel高度和deferredRender、layoutOnTabChange兩個(gè)屬性來(lái)調(diào)整
id:'tpProduct',
deferredRender:false,//是否第一次顯示就渲染所有tab(默認(rèn)為true)
layoutOnTabChange:true,
//height:300,
//autoTabs:true,
activeTab:0,
border:false,
items:[
pnProduct,
pnCategory
]
});
var fpProduct=new Ext.FormPanel({//作為TabPanel的容器
id:'fpProduct',
reader: new Ext.data.JsonReader({
successProperty: 'success',//后臺(tái)返回的json中成功與否的字段名稱
root: 'info'//后臺(tái)返回的json中,數(shù)據(jù)字段名稱
},
[
'ProductName',
//'Discontinued',
'QuantityPerUnit',
'UnitPrice',
'UnitsInStock',
'CategoryID',
'CategoryName',
'Description',
'SupplierID'
]
),
items:[
tpProduct
]
});
var winProductInfo=new Ext.Window({
title:'商品信息',
width:450,
height:300,
layout:'fit',
closeAction:'hide',
plain:true,//true則主體背景透明,false則和主體背景有些差別
collapsible:true,//是否可收縮
modal:true,//是否為模式窗體
items:[
fpProduct
],
buttons:[//窗體按鈕
{
text:'提交',
handler:function(){
if(fpProduct.getForm().isValid()){
var record=grdProduct.getSelectionModel().getSelected();
fpProduct.getForm().submit({
method:'post',
url:'ProductInfo.aspx?type=updateProductInfo&productId='+record.get("ProductID"),
waitMsg:'數(shù)據(jù)更新中...',
success:function(){
stProduct.reload();
Ext.Msg.alert("系統(tǒng)提示","提交成功!");
},
failure:function(){
Ext.Msg.alert("系統(tǒng)提示","提交失敗!");
}
});
}
}
},
{
text:'關(guān)閉',
handler:function(){//點(diǎn)擊時(shí)觸發(fā)的事件
winProductInfo.hide();
}
}
]
});
// Ext.getCmp('tp').on("tabchange",function(tabPanel,tab){
// Ext.Msg.alert("系統(tǒng)提示","Tab標(biāo)題:"+tab.title);
// });
grdProduct.on("rowdblclick",function(grid,rowIndex,e){
var row=grid.getStore().getAt(rowIndex).data;
//Ext.Msg.alert("系統(tǒng)提示","行:"+rowIndex+" 產(chǎn)品ID:"+row.ProductID);
fpProduct.form.load({//利用load自動(dòng)填充,注意表單控件字段一定要和json中一致
url:'ProductInfo.aspx?type=getProductInfo&productId='+row.ProductID,
waitMsg:'數(shù)據(jù)加載中...',
success:function(){
//alert("tempFile/"+row.CategoryName+".png");
if(row.Discontinued=="是"){
Ext.getCmp('DiscontinuedOneID').setValue(true);
}else{
Ext.getCmp('DiscontinuedTwoID').setValue(true);
}
Ext.getCmp('CategoryImage').getEl().dom.src="tempFile/"+row.CategoryName+".png";
},
failure:function(){
Ext.Msg.alert("系統(tǒng)提示","數(shù)據(jù)加載失敗!");
}
});
winProductInfo.show();
});
var pnCenter=new Ext.Panel({
id:'pnCenter',
region:'center',
items:[
grdProduct
]
});
var vp=new Ext.Viewport({
id:'vp',
layout:'border',
renderTo:Ext.getBody(),
items:[
pnNorth,
pnCenter
]
});
});
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 久草在线视频免费播放 | 欧美一级淫片免费视频1 | 草久在线| 草草视频免费 | 高清国产在线 | 黄色免费高清网站 | www.精品久久 | 毛片免费试看 | 欧美在线观看视频一区 | 国产精品久久久久久久久久10秀 | 国产1区在线 | 精品国产高清一区二区三区 | 欧美一级精品片在线看 | av手机在线免费播放 | 一级黄色免费观看 | 秋霞a级毛片在线看 | 久久伊人国产精品 | 久久久久久久高清 | 色婷婷久久久亚洲一区二区三区 | 国产午夜精品理论片a级探花 | 精品一区二区久久久久久按摩 | 香蕉成人在线观看 | 久草在线手机视频 | 国产无限资源在线观看 | 精品人人人人 | av在线免费看片 | 国产午夜三级一区二区三桃花影视 | 欧美黑人伦理 | 成人啪啪18免费网站 | 国产伦精品一区二区三区在线 | 久久久www成人免费精品 | 国产成人综合在线观看 | 热99精品视频 | 黄色片网站免费在线观看 | 一级毛片免费高清 | 成人区一区二区 | 国产做爰全免费的视频黑人 | 一区二区三区视频播放 | 91福利影视 | 91精品国 | 欧美日韩免费在线观看视频 |