2013-03-15 2 views
1

내 응용 프로그램의 페이징 도구 모음에 문제가 있습니다. 내 저장소는 MySQL 데이터베이스 테이블을 JSON 데이터로 변환하는 PHP 스크립트로 채워집니다.다음 및 이전 단추 무시 도구 모음 sencha extjs 4.1

내 창에는 그리드를 필터링하는 데 사용하는 양식이있는 패널이 있습니다. 모든 "필터"는 store.load() 호출로 매개 변수로 전달되며 PHP 스크립트는 쿼리를 완료하고 데이터를 반환합니다.

내 문제는 일부 필터가있을 때 페이징 도구 모음의 다음 단추를 클릭하면 필자의 필터가 사라지고 추가 매개 변수없이 저장됩니다. nextPage()/prevPage() 호출에서 추가 매개 변수를 보내려면 어떻게해야합니까?

편집 : 나는 store.on('beforeload')를 사용하여 해결 , 여기 내 솔루션입니다 :

당신은 MoveNext를 및 페이징 도구 모음의 movePrevious 메소드를 오버라이드 (override) 할 필요가
store.on('beforeload', function(store, operation, opts){ 
    operation.params={ 
     // yuor params here 
     param1: param1Value, 
     param2: param2Value 
    }; 
}, this); 

답변

0

, 이러한 방법으로 모든 사용자 정의 PARAMS 포함 된 개체를 전달할 수 당신은 쉽게 현재의 문제가 해결됩니다 PHP

/** 
* Move to the next page, has the same effect as clicking the 'next' button. 
*/ 
moveNext : function(){ 
    var me = this, 
     total = me.getPageData().pageCount, 
     next = me.store.currentPage + 1; 

    if (next <= total) { 
     if (me.fireEvent('beforechange', me, next) !== false) { 
      me.store.nextPage({ 
       // all the custom params should go here 
       param1 : 'value1' 
      }); 
     } 
    } 
} 

이를 통과해야하지만, 이전/다음 페이지가 일에서 가져올 때 매장이 사용자 정의 PARAMS 매번를 제공 할 것입니다 일반적인 수정을 원하는 경우 광석은 당신이 loadPage 방법을 무시하고이 사용자 정의 PARAMS을 추가 할 수 있습니다

loadPage: function(page, options) { 
    var me = this; 

    me.currentPage = page; 

    // add your custom params 
    options = Ext.apply({ 
     param1 : 'value1' 
    }, options); 

    // Copy options into a new object so as not to mutate passed in objects 
    options = Ext.apply({ 
     page: page, 
     start: (page - 1) * me.pageSize, 
     limit: me.pageSize, 
     addRecords: !me.clearOnPageLoad 
    }, options); 

    if (me.buffered) { 
     return me.loadToPrefetch(options); 
    } 
    me.read(options); 
} 

참조 :

http://docs.sencha.com/ext-js/4-1/source/Paging.html#Ext-toolbar-Paging

http://docs.sencha.com/ext-js/4-1/source/Store.html#Ext-data-Store-method-nextPage 당신이 답을 찾았지만 내가 같은 문제가 있다면 잘 모릅니다

+0

가 작동하지 않습니다 ,이 솔루션을 시도하는 매개 변수를 사용하고 난 가게 Next (다음)를 클릭하면 매개 변수없이 다시로드됩니다. 위 질문에 내 코드를 게시했습니다. – andyts93

0

여기 내가 찾은 것이 있습니다.

희망이 있습니다.

매개 변수가있는 전화를 걸면 한 번만 표시됩니다. 이전 버전에서 Sencha는 baseParams를 사용하라고 말했지만 더 새로운 것들에서 찾을 수는 없었습니다. 그래서 프록시의 extraParams이 방법을 사용 :

이 내가 내 데이터를 필터링하는 데 사용하는 형태의 버튼입니다

text: 'Filter', 
handler: function() { 
     /* 
     get the form 
     get a record object and set its data 
     */ 
     var form = this.up('form').getForm(); 
     var record = form.getRecord(); 
     form.updateRecord(record); 

     for(name in record.data){ 
      if (record.data.hasOwnProperty(name)) 
       envelopeStore.setExtraParam(name, record.data[name]); 
     } 
     /* 
     envelopeStore.getProxy().extraParams = record.data; 
     *I have some constant params so I needed to add them in a loop as above 
     *you can simply use this 
     */ 

     envelopeGrid.child('pagingtoolbar').moveFirst(); 
     /* 
     do not load store data. It does not change paging. go to first page instead 
     */ 
    }  
관련 문제