'분류 전체보기'에 해당되는 글 126건

  1. 2011.10.04 ExtJS4 모바일 스크롤 문제 해결 1
  2. 2011.08.13 Extjs AutoID
  3. 2011.08.10 store에 object 삽입
  4. 2011.08.07 extjs4 무한 스크롤 (infinite scroll)
  5. 2011.07.17 Event Observer
  6. 2011.07.06 property.Grid에 사용자 콤보 추가. 2
  7. 2011.07.06 Combobox 변경시
  8. 2011.07.06 reconfigure
  9. 2011.07.04 Ext 3 to 4 Migration
  10. 2011.07.01 경고창에 이벤트 주기
자바스크립트/Ext JS2011. 10. 4. 19:57

요구사항 : 고객은 현재 개발 된 시스템(Extjs기반)이 모바일에서도 작동되게 해달라고 한다.
               그러나 PC버전이 모바일(갤탭)에서 잘 돌아가리란 보장이 없는 관계로 테스트를 해보던 중
               결정적으로 스크롤 특히 그리드가 문제가 생겼다. PC에서는 우측 스크롤과 하단 스크롤이 
               보이지만 모바일로 넘어가면 스크롤이 없어지고 데이터가 묻혀버리는 현상이 발생한다.
               이 부분을 해결하기 위해서 구글링을 한 결과 2가지 대안을 찾았다. 

대안 1 : 모바일일 경우 Ext의 그리드를 override하여 터치모드로 작동되도록 변형할 수 있다.
           아래 링크를 통해 확인 할 수 있다. 아래 링크를 갤탭에서 실행하면 터치기능이 작동된다.
http://www.rahulsingla.com/sites/default/files/content/blog/extjs-iscroll/scrolling-ext-containers-on-touch-devices.htm
          소스를 잠깐 보면 Panel, Tree, Grid를 override하고 있다. 이렇게 되면 공통 js에 아래코드를 넣고 사용한다면
           모든 프로그램에 아래 내용이 적용되어 모바일에서는 자동으로 좌우스크롤이 생성되고 터치 기능으로 작동이 가능하다.
           직접 실행해보면 상당히 괜찮을 결과를 얻을 수 있다. 이는 모바일에서 사용되는 iScroll모듈을 Extjs에 적용한 것이다.
           인도 친구 인것 같은데 아이디어가 좋은 것 같다. 그러나 문제가 한가지 있다. 우리 시스템은 ExtJs4기반이고 아래
           소스는 Extjs3버전이다. 그래서 마이그레이션해서 버전을 올려보려 했으나 결정적으로 아래소스에서 보듣이
           Extjs3버전에서는 스크롤의 아이디가 '.x-grid3-scroller'로 정해져 있으나 ExtJS4에서는 이부분이 AutoId로 되어 있어
           스크롤 영역을 특정짓지 못하게 된다. 결국 삽질을 거듭하다 포기하고 다른 대안을 찾도록 했다.
			Ext.isiPad = navigator.userAgent.match(/iPad/i) != null;
			Ext.isiPhone = navigator.userAgent.match(/iPhone/i) != null;
			//TODO: Add support for more devices like Android etc. here.
			Ext.isMobileDevice = Ext.isiPad || Ext.isiPhone;

			///////////////////////////////////////////////////////////
			//iScroll Overrides
			Ext.override(Ext.Panel, {
				afterRender: Ext.Panel.prototype.afterRender.createSequence(function() {
					if (this.getXType() == 'panel') {
						this._getIScrollElement = function() {
							return (this.el.child('.x-panel-body', true));
						}
					}

					//Uncomment below to use iScroll only on mobile devices but use regular scrolling on PCs.
					if (this.autoScroll /*&& Ext.isMobileDevice*/) {
						if (this._getIScrollElement) {
							this._updateIScroll();
							this.on('afterlayout', this._updateIScroll);
						}
					}
				}),

				_ensureIScroll: function() {
					if (!this.iScroll) {
						var el = this._getIScrollElement();
						if (el.children.length > 0) {
							this.iScroll = new iScroll(el);
							this.iScrollTask = new Ext.util.DelayedTask(this._refreshIScroll, this);
						}
					}
				},

				_updateIScroll: function() {
					this._ensureIScroll();
					if (this.iScroll) {
						this.iScrollTask.delay(1000);
					}
				},

				_refreshIScroll: function() {
					this.iScroll.refresh();
					//Refresh one more time.
					this.iScrollTask.delay(1000);
				}
			});

			Ext.override(Ext.tree.TreePanel, {
				_getIScrollElement: function() {
					return (this.el.child('.x-panel-body', true));
				}
			});

			Ext.override(Ext.grid.GridPanel, {
				_getIScrollElement: function() {  // 아래 부분이 Extjs에서 그리드위에 생성되는 스크롤이다. 
					return (this.el.child('.x-grid3-scroller', true)); // 이부분이 스크롤 된다.
				},

				afterRender: Ext.grid.GridPanel.prototype.afterRender.createSequence(function() {
					//TODO: need to hook into more events and to update iScroll.
					this.view.on('refresh', this._updateIScroll, this);
				})
			});


대안 2 : 최초 고객은 두손가락 스크롤을 원했다. 즉 패드종류에서는 기존의 스크롤 대신 두 손가락으로 슬적 밀면 스크롤이 되도록
            지원하고 있다. 개인적으로 절대 이 기능으로 실사용자들이 만족하지 못할 거라는 판단하에 이부분을 첨부터 알아보지
            않고 대안1에 치중하였으나 대안1이 어려우니 이거라도 구현해주려고 한다.
            일단 이 것이 가능하려면 약간 수정 해줘야 한다. 아래의 autoScroll부분이 true일 경우 모바일에서 두손가락 스크롤이
            가능하다.
    createGridPanel: function(){
        this.gridPanel = Ext.create('widget.EmStock.gridPanel', {
            region: 'center',
            store : this.store,
            pageSessionId : this.pageSessionId,
            floatable: false,
            defaults:{ autoScroll:Ext.isiPad || Ext.isiPhone },  // 이 부분이 꼭 필요하다. 패드나 폰일 경우 true를 리턴한다. 갤탭일 경우 그냥 true
            padding: '10 0 0 0',
            totalCount : this.totalCount, 
            split: 	true,
            listeners: {
                scope: this,
                ongridselect: this.onGridSelect,
                columnhide : this.onColumnHide,
                refreshgrid : this.refreshGrid
            }
        });
        
        return this.gridPanel;
    },

'자바스크립트 > Ext JS' 카테고리의 다른 글

[ExtJS4] Gestting Started  (0) 2011.12.22
ExtJS 기반 시스템 구성도  (2) 2011.10.05
Extjs AutoID  (0) 2011.08.13
store에 object 삽입  (0) 2011.08.10
extjs4 무한 스크롤 (infinite scroll)  (0) 2011.08.07
Posted by 베니94
자바스크립트/Ext JS2011. 8. 13. 00:26

getAutoId: function() {
        return ++Ext.AbstractComponent.AUTO_ID;
    },

'자바스크립트 > Ext JS' 카테고리의 다른 글

ExtJS 기반 시스템 구성도  (2) 2011.10.05
ExtJS4 모바일 스크롤 문제 해결  (1) 2011.10.04
store에 object 삽입  (0) 2011.08.10
extjs4 무한 스크롤 (infinite scroll)  (0) 2011.08.07
Event Observer  (0) 2011.07.17
Posted by 베니94
자바스크립트/Ext JS2011. 8. 10. 14:35


// Create a record instance through the ModelManager
                var r = Ext.ModelManager.create({
                    name: 'New Guy',
                    email: 'new@sencha-test.com',
                    start: new Date(),
                    salary: 50000,
                    active: true
                }, 'Employee');

                store.insert(0, r);

'자바스크립트 > Ext JS' 카테고리의 다른 글

ExtJS4 모바일 스크롤 문제 해결  (1) 2011.10.04
Extjs AutoID  (0) 2011.08.13
extjs4 무한 스크롤 (infinite scroll)  (0) 2011.08.07
Event Observer  (0) 2011.07.17
property.Grid에 사용자 콤보 추가.  (2) 2011.07.06
Posted by 베니94
자바스크립트/Ext JS2011. 8. 7. 21:20
그리드는 일반적으로 웹에서 표현될 때 페이징이 되어 보여진다. 그러나 웹인데도 불구하고 대량에 데이터를 보여줘야할
경우가 있다. 일단 2천~3천건 정도를 보여줘야할 경우가 있는데 페이징을 고객이 꺼려한다.
출력은 되지만 천건 이상 출력될 경우 화면 전환이나 이동, 리사이징 등이 당연히 느려질 수 밖에 없다.
그래서 infinite scroll(무한 스크롤을 사용하기로 했다.)
근데 이놈이 문제가 좀 있다. 샘플을 그대로 사용하기에는 문제가있었다. 검색 버튼을 클릭하고 2번째 검색을 다시 했을 경우
스크롤이 정상적인 위치에 있지 않고 그리드내의 페이지 위치와 스크롤 위치가 어긋나는 현상이 발생한다.

이걸 어떻게 맞춰줄 까 싶어 구글링 해보니 방법을 찾았다. 아래의 글을 참고해서 override한 클래스를 이용하면
http://www.sencha.com/forum/showthread.php?133337-desire-to-reload-the-buffered-scrolling-example-with-different-data-via-user-action&p=602983

재 검색시 스크롤 바를 맨 위로 맞춰주게 된다. 더 구체적으로 쓰고 싶지만 나중에 정리하자.




위의 그림을 보면 스크롤을 계속하면 페이지별로 서버에 요청하는 것을 볼 수 있다. 근데 단점은 전체 데이터를 모두 가지고 있으면
로컬 소팅이나 로컬 검색이 가능하지만 이 경우에는 컬럼을 클릭해서 소팅을 다시 할 경우 로컬 소트가 아닌 리모트 소트를 적용
해서 다시 데이터를 원천적으로 해야한 다는 건데..
암튼 이런 형태로 구현하면 눈속임이지만 수만건의 데이터도 보여지게 할 수 있다.

'자바스크립트 > Ext JS' 카테고리의 다른 글

Extjs AutoID  (0) 2011.08.13
store에 object 삽입  (0) 2011.08.10
Event Observer  (0) 2011.07.17
property.Grid에 사용자 콤보 추가.  (2) 2011.07.06
reconfigure  (0) 2011.07.06
Posted by 베니94
자바스크립트/Ext JS2011. 7. 17. 13:18

function captureEvents(observable) {
    Ext.util.Observable.capture(
        observable,
        function(eventName) {
            console.info('event :::',eventName, observable);
        },
        this
    );  
}

captureEvents("감시할 대상");

'자바스크립트 > Ext JS' 카테고리의 다른 글

store에 object 삽입  (0) 2011.08.10
extjs4 무한 스크롤 (infinite scroll)  (0) 2011.08.07
property.Grid에 사용자 콤보 추가.  (2) 2011.07.06
reconfigure  (0) 2011.07.06
Ext 3 to 4 Migration  (0) 2011.07.04
Posted by 베니94
자바스크립트/Ext JS2011. 7. 6. 16:53
Ext.require([
		'Ext.button.Button',
		'Ext.grid.property.Grid'
	]);
	
	Ext.onReady(function(){
		// simulate updating the grid data via a button click
		
		var Unit = Ext.create('Ext.data.Store', {
			fields: ['abbr', 'name'],
				data : [
					{"abbr":"AUstralian", "name":"AUD"},
					{"abbr":"Canadian", "name":"CND"},
					{"abbr":"Europe", "name":"EUR"},
					{"abbr":"british", "name":"GBP"},
					{"abbr":"indian", "name":"INR"},
					{"abbr":"united", "name":"USD"}
				]
			});
		
		var Scale = Ext.create('Ext.data.Store', {
			fields: ['abbr', 'name'],
				data : [
				{"abbr":"AUstralian", "name":"actual"},
				{"abbr":"Canadian", "name":"crore"},
				{"abbr":"Europe", "name":"hundred"},
				{"abbr":"british", "name":"lakh"},
				{"abbr":"indian", "name":"million"},
				{"abbr":"united", "name":"thousand"}
				]
			});
		
		var propsGrid = Ext.create('Ext.grid.property.Grid', {
			width: 300,
			renderTo: 'smpl',
			customEditors: {
				Unit: Ext.create('Ext.form.ComboBox', {                       
					store: Unit,
					queryMode: 'local',
					displayField: 'name',
					valueField: 'abbr',
					editable: false
				}),
				Scale: Ext.create('Ext.form.ComboBox', {                                         
					store: Scale,
					queryMode: 'local',
					displayField: 'name',
					valueField: 'abbr',
					editable: false
				})
			},
			source: {
				"Name": "Properties Grid",
				"(ID)": 'id',
				"Type": true,
				"SubGroup": false,
				"PeriodType": Ext.Date.parse('10/15/2006', 'm/d/Y'),
				"Balance": false,
				"abstract": 0.01,
				"Nullable": 1,
				"Unit": 'USD',
				"Scale":'actual'
			}
		});
	});

'자바스크립트 > Ext JS' 카테고리의 다른 글

extjs4 무한 스크롤 (infinite scroll)  (0) 2011.08.07
Event Observer  (0) 2011.07.17
reconfigure  (0) 2011.07.06
Ext 3 to 4 Migration  (0) 2011.07.04
경고창에 이벤트 주기  (0) 2011.07.01
Posted by 베니94
카테고리 없음2011. 7. 6. 10:33

comboboxA.on("change", function(cb, newValue, oldValue){

    if(newValue == "USA"){
       comboboxB.store.loadData(["Texas", "New York", "Washington"]);
       comboboxB.setValue("Texas");
    }
    else if(newValue == "England"){
       comboboxB.store.loadData(["London", "Manchester"]);
       comboboxB.setValue("London");
    }

});
Posted by 베니94
자바스크립트/Ext JS2011. 7. 6. 10:31

// or an object with an Ext.data.Field ('dynamic') 
var fields = ['totally', {name : 'dynamic', type : 'string'}]; 
var newStore = new MyApp.store.Object({ 
  fields
: fields 
 
// other options like proxy, autoLoad... 
}); 

Don't specify a model property - it seems that it would override the fields property.

I also wanted to change the columns and content of an existing grid dynamically:

// reconfigure the grid to use the new store and other columns 
var newColumns = [ 
 
{header: 'Totally', dataIndex: 'totally'}, 
 
{header: 'Dynamic', dataIndex: 'dynamic'} 
]; 
myGrid
.reconfigure(newStore, newColumns); 

'자바스크립트 > Ext JS' 카테고리의 다른 글

Event Observer  (0) 2011.07.17
property.Grid에 사용자 콤보 추가.  (2) 2011.07.06
Ext 3 to 4 Migration  (0) 2011.07.04
경고창에 이벤트 주기  (0) 2011.07.01
form 요소 전체 보기  (0) 2011.07.01
Posted by 베니94
자바스크립트/Ext JS2011. 7. 4. 21:32
/** JSON.decode의 버젼별 코드 
*/
// ExtJS 3
obj = Ext.util.JSON.decode(action.response.responseText);

// ExtJS 4
obj = Ext.JSON.decode(action.response.responseText);

'자바스크립트 > Ext JS' 카테고리의 다른 글

property.Grid에 사용자 콤보 추가.  (2) 2011.07.06
reconfigure  (0) 2011.07.06
경고창에 이벤트 주기  (0) 2011.07.01
form 요소 전체 보기  (0) 2011.07.01
ExtJs Ajax  (0) 2011.06.27
Posted by 베니94
자바스크립트/Ext JS2011. 7. 1. 21:05

Ext.Msg.alert('click', Ext.getCmp('gubun2').getValue(), function(btn){
                  if(btn == 'ok'){
                   //Ext.getCmp('cmp_nm').setValue('11');
                  }
                 });

'자바스크립트 > Ext JS' 카테고리의 다른 글

reconfigure  (0) 2011.07.06
Ext 3 to 4 Migration  (0) 2011.07.04
form 요소 전체 보기  (0) 2011.07.01
ExtJs Ajax  (0) 2011.06.27
ajax를 통해 extjs 코드 가져오기  (0) 2011.06.27
Posted by 베니94