ExtJSサンプルまとめ-1
28571 ワード
extjs 2:http://tianya23.blog.51cto.com/1081650/821649
1、コンボボックス
absolute
名前の通り、コンテナ内部に指定された座標に基づいて位置を指定します。accordon これが一番覚えやすいです。アコーディオンの効果です。 アンチョー この効果は具体的には何の効果があるか分かりません。注意してください。 1.容器内のセットは幅を指定するか、アンチョーで高さ・幅を同時に指定するか、 2.アンチョー値は通常負の値しかできません。正の値は意味がありません。 3.アンチョーは文字列の値でなければなりません。
border 容器を5つの区域に分けます。east、south、west、north、センター card ウィザードをインストールするように、一枚ずつ表示します。 column 容器全体を一列と見なし、容器にサブ元素を入れる場合。fit 一つのサブ要素は容器全体に満ちます。複数のサブ要素が一つの要素だけが容器全体に満ちています。 form フォーム内の入力フィールドを管理するためのレイアウトです。 テーブル 普通の表の方法によって、サブ要素をレイアウトし、ラyoutConfig:{columns:3}、//親容器を3列に分けます。
3、ページをめくる効果Ext.onReady(function() { var i = 0; var navHandler = function(direction) { if (ディレクション == -1) { i--; if (i < 0) { i = 0; } } if (ディレクション == 1) { i++; if (i > 2) { i = 2. return false; } } var btnNext = Ext.get(「move-next」); var btnBack = Ext.get(「move-next」); if (i == 0) { btnBack.disabled = true; } else { btnBack.disabled = false; } if (i == 2) { btnNext.value = 仕上げる btnNext.disabled = true; } else { btnNext.value = 次のステップ btnNext.disabled = false; } card.get Layout().setActiveItem(i) }; var カード = new Ext.Panel({ width: 200, height: 200, title: '登録ウィザード、 ラyout: 'カード activeItem: 0, // メーク sure the active アイテム is セット オン the container config bodyStyle: 'padding:15 px' defaults: { border: false }, bar: [ { id: 'move-prev'は、 テキスト: '前のステップ ハンドル: navHandler.creat Delegate(this、 [-1]) }, '->', { id: 'move-next テキスト: '次のステップ ハンドル: navHandler.creat Delegate(this、 [1] } ], アイテム: [{ id: 'card-0' html数: '登録ガイドへようこそ! }, { id: 'card-1 html数: '登録資料を記入してください。 }, { id: 'card-2 html数: '登録成功! }], レンデター: 「container」 }); } 4、render、render To、aplayTo、el、ショーの説明
1.コンポーネントのレンダーメソッドを呼び出す panel.render('div');2.構成でrender To属性を指定します。 rendent:'div',3.構成ではappyToを指定します。これはこの属性の親要素に要素を提示します。 appyTo:'divChild'は、4.el属性を指定することにより、指定後にレンダーメソッドを呼び出します。 el:'div' panel.render();5.show方法を呼び出します。 panel.show()//一般的にはhideによって表示されている要素でまとめられています。elとrender Toは似ています。いずれもあるHTML要素にレンダリングされています。
5、FormPanel使用
frame:true
Trueはパネルの外枠としてカスタマイズ可能であり、falseは外枠の1 pxが可能な点線(デフォルトはfalse)を表しています。
8、cobo使用
label Width:50、
label Align:'right'
10、デバッグ
chrome:scripts->デバッグが必要なjsファイルを選択し、ブレークポイントでデバッグを行う
ctrl+shift+i後:network->documentsでrequest転送のパラメータが確認できます。
11、Ajax連動メニューの実現
1、コンボボックス
- new Ext.onReady(function(){
- var top = new Ext.FormPanel({
- labelAlign: 'top',
- frame:true,
- title: 'Multi Column, Nested Layouts and Anchoring',
- bodyStyle:'padding:5px 5px 0',
- width: 600,
- items: [{
- layout:'column',
- items:[{
- columnWidth:.5,
- layout: 'form',
- items: [{
- xtype:'textfield',
- fieldLabel: 'First Name',
- name: 'first',
- anchor:'95%'
- }, {
- xtype:'textfield',
- fieldLabel: 'Company',
- name: 'company',
- anchor:'95%'
- }]
- },{
- columnWidth:.5,
- layout: 'form',
- items: [{
- xtype:'textfield',
- fieldLabel: 'Last Name',
- name: 'last',
- anchor:'95%'
- },{
- xtype:'textfield',
- fieldLabel: 'Email',
- name: 'email',
- vtype:'email',
- anchor:'95%'
- }]
- }]
- },{
- xtype:'htmleditor',
- id:'bio',
- fieldLabel:'Biography',
- height:200,
- anchor:'98%'
- }],
-
- buttons: [{
- text: 'Save'
- },{
- text: 'Cancel'
- }]
- });
-
- top.render(document.body);
- }) ;
2、ページレイアウト:layout、参考:http://virgoooos.iteye.com/blog/288924 absolute
名前の通り、コンテナ内部に指定された座標に基づいて位置を指定します。
3、ページをめくる効果
Step 1 保存先 3
'Step 2 保存先 3
'Step 3 保存先 3 - Complettee
'1.コンポーネントのレンダーメソッドを呼び出す panel.render('div');2.構成でrender To属性を指定します。 rendent:'div',3.構成ではappyToを指定します。これはこの属性の親要素に要素を提示します。 appyTo:'divChild'は、4.el属性を指定することにより、指定後にレンダーメソッドを呼び出します。 el:'div' panel.render();5.show方法を呼び出します。 panel.show()//一般的にはhideによって表示されている要素でまとめられています。elとrender Toは似ています。いずれもあるHTML要素にレンダリングされています。
5、FormPanel使用
- var simple = new Ext.FormPanel({
- labelWidth : 75, // label settings here cascade unless overridden
- url : 'save-form.php',
- frame : true,
- title : 'Simple Form',
- bodyStyle : 'padding:5px 5px 0',
- width : 350,
- defaults : {
- width : 230
- },
- defaultType : 'textfield',
-
- items : [ {
- fieldLabel : 'First Name',
- name : 'first',
- allowBlank : false
- }, {
- fieldLabel : 'Last Name',
- name : 'last'
- }, {
- fieldLabel : 'Company',
- name : 'company'
- }, {
- fieldLabel : 'Email',
- name : 'email',
- vtype : 'email'
- }, new Ext.form.TimeField({
- fieldLabel : 'Time',
- name : 'time',
- minValue : '8:00am',
- maxValue : '6:00pm'
- }) ],
-
- buttons : [ {
- text : 'Save'
- }, {
- text : 'Cancel'
- } ]
- });
- simple.render(document.body);
6、viewportとborderのレイアウト
- new Ext.Viewport({
- layout: 'border',
- items: [{
- region: 'north',
- html: '<h1 class="x-panel-header">Page Title</h1>',
- autoHeight: true,
- border: false,
- margins: '0 0 5 0'
- }, {
- region: 'west',
- collapsible: true,
- title: 'Navigation',
- width: 200
- // the west region might typically utilize a TreePanel or a Panel with Accordion layout
- }, {
- region: 'south',
- title: 'Title for Panel',
- collapsible: true,
- html: 'Information goes here',
- split: true,
- height: 100,
- minHeight: 100
- }, {
- region: 'east',
- title: 'Title for the Grid Panel',
- collapsible: true,
- split: true,
- width: 200,
- xtype: 'grid',
- // remaining grid configuration not shown ...
- // notice that the GridPanel is added directly as the region
- // it is not "overnested" inside another Panel
- }, {
- region: 'center',
- xtype: 'tabpanel', // TabPanel itself has no title
- items: {
- title: 'Default Tab',
- html: 'The first tab\'s content. Others may be added dynamically'
- }
- }]
- });
6、store、model
- Ext.onReady(function() {
- var myStore = new Ext.data.ArrayStore({
- fields: ['id','fullname', 'first'],
- idIndex: 0 // id for each record will be the first element
- });
- var myData = [
- [1, 'Fred Flintstone', 'Fred'], // note that id for the
- // record is the first
- // element
- [2, 'Barney Rubble', 'Barney']
- ];
-
-
- myStore.loadData(myData);
-
- myStore.each(function(model) {
- alert(model.get('fullname'));
- });
- });
7、パネル全体の色調を揃えるframe:true
Trueはパネルの外枠としてカスタマイズ可能であり、falseは外枠の1 pxが可能な点線(デフォルトはfalse)を表しています。
8、cobo使用
- new Ext.onReady(function() {
- var mystore = new Ext.data.ArrayStore({
- fields : [ 'myId', 'displayText' ],
- data : [ [ 1, 'ALL' ], [ 2, 'IP' ], [ 3, 'COOKIE' ] ]
- });
- var top = new Ext.FormPanel({
- width : 600,
- height : 400,
- title : 'hello',
- labelWidth: 50,
- labelAlign:'right',
- bodyStyle : 'padding:5px 5px 10 10',
- frame : true,
- defaults : {
- xtype : 'combo',
- width : 120,
- height : 20,
- typeAhead: true,
- triggerAction: 'all',
- lazyRender:true,
- mode: 'local',
- valueField: 'myId',
- displayField: 'displayText'
- },
- items : [ {
- fieldLabel : 'lable1',
- store : mystore
- }
- , {
- fieldLabel : 'lable2',
- store : mystore
- }, {
- fieldLabel : 'lable3',
- store : mystore
- }, {
- fieldLabel : 'lable4',
- store : mystore
- }, {
- fieldLabel : 'lable5',
- store : mystore
- }, {
- fieldLabel : 'lable6',
- store : mystore
- }, {
- fieldLabel : 'lable7',
- store : mystore
- }, {
- fieldLabel : 'lable8',
- store : mystore
- } ],
- buttons : [ {
- text : 'save'
- }, {
- text : 'cancel'
- } ]
- });
-
- top.render(document.body);
- });
9、labelラベルとcompboの間の距離を調整する。label Width:50、
label Align:'right'
10、デバッグ
chrome:scripts->デバッグが必要なjsファイルを選択し、ブレークポイントでデバッグを行う
ctrl+shift+i後:network->documentsでrequest転送のパラメータが確認できます。
11、Ajax連動メニューの実現
- (function(){
- function createChild(value,name){
- var el = document.createElement("option");
- el.setAttribute("value",value);
- el.appendChild(document.createTextNode(name));
- return el;
- }
- var data = {};
-
- Ext.onReady(function(){
- //1. city dom
- var cityObj = Ext.get("city");
- //2. city change
- cityObj.on("change",function(e,select){
- //3.
- var ids = select.options[select.selectedIndex].value;
- //3.1 ,
- if(data["city"]){
- //
- }else{
- // ajax
- }
- //4.ajax
- Ext.Ajax.request({
- url:'/extjs/extjs!menu.action',
- params:{ids:ids},
- method:'post',
- timeout:4000,
- success:function(response,opts){
- var obj = eval(response.responseText);
- //5. area DOM
- var oldObj = Ext.get("area").dom;
- //6.
- while(oldObj.length>0){
- oldObj.options.remove(oldObj.length-1);
- }
- //7.
- Ext.Array.each(obj,function(o){
- Ext.get('area').dom.appendChild(createChild(o.valueOf(),o.name));
- })
- //8.
- }
- });
- });
- });
- })()