2012-03-02 2 views
1

I는 격자 안에 itemselecor 있고, 내가 itemselector 내부에만 저장소를 다시로드한다 콤보가 여기 Extjs4는 - itemselector 내부 저장소를 다시로드

는 itemselector

있다 (값 필드를 그대로 유지해야 함)

var grid = Ext.widget('form', { 
     id: 'grid', 
     title: '', 
     width: 600, 
     bodyPadding: 10, 
     renderTo: 'itemselectorproduto', 
     items: [{ 
      xtype: 'itemselector', 
      name: 'itemselector', 
      id: 'itemsel', 
      anchor: '100%', 
      imagePath: '/ux/images/', 
      store: store, 
      displayField: 'Nome', 
      valueField: 'ID', 
      value: vitrine, 
      allowBlank: true, 
      msgTarget: 'side' 
     }] 
    }); 
나는 일반 store.load()를 호출하려하지만 아무런 영향을 미치지하고 콘솔에 오류를 보여줍니다

필요한 경우 내가 코드의 더 게시 할 예정입니다,하지만 난 그냥이 있어야한다고 생각합니다 충분

고마워요,

답변

0

코드를 살펴보면 ItemSelector가 보이지 않는 경우 상점에서 변경된 사항을 지원합니다. 기본적으로 데이터의 로컬 복사본을 만듭니다. 그리고 bindStore 메서드를 호출하여 다른 저장소를 지정하면 선택 항목이 지워집니다.

ItemSelector의 코드를 향상시켜 이러한 동작을 허용 할 수 있습니다. 그것은 문제가되어서는 안됩니다. 바인딩 할 때 저장소의 데이터 연결 또는로드 이벤트에 가입 한 다음 저장소 데이터가 변경 될 때 상황을 처리 할 수 ​​있습니다.

+0

내가 처음 가게를 store.load ({{descontoid : descontoid, categoriaid : PARAMS는 null}}) 다시로드하는 방법이다; 이 선은 그리드에서 작동하지만 물론 항목 선택자를위한 것입니다. – Beoulve

+0

그리드 안에 itemselector는 어떻게 있습니까? 그것은 세포 안에 있습니까? – sha

+0

gridse 내부 항목으로 itemselector를 사용하고 있었지만 조금 혼란스러워서 바뀌지 않았습니다. 위의 그림은 격자 외부에 itemselector를 만들고 항목 – Beoulve

0

사실 나는 이런 일을하는 가장 좋은 방법은 ItemSelector`s "populateFromStore"를 사용하는 것이라고 생각합니다. 품목 선택기를 확장하는 것을 제외하고는 확실합니다. 확장의 경우 ItemSelector의 "onBindStore"함수를 살펴 봐야합니다.

onBindStore: function(store, initial) { 
    var me = this; 

    if (me.fromField) { 
     me.fromField.store.removeAll() 
     me.toField.store.removeAll(); 

     // Add everything to the from field as soon as the Store is loaded 
     if (store.getCount()) { 
      me.populateFromStore(store); 
     } else { 
      me.store.on('load', me.populateFromStore, me); 
     } 
    } 
} 

따라서 빈 저장소의 경우로드 이벤트에 연결됩니다. 그리고 그것은 다음과 같이해야합니다 :

여기
onBindStore: function(store, initial) { 
    var me = this; 

    if (me.fromField) { 
     me.fromField.store.removeAll() 
     me.toField.store.removeAll(); 

     me.store.on('load', me.populateFromStore, me); 
     // Add everything to the from field as soon as the Store is loaded 
     if (store.getCount()) { 
      me.populateFromStore(store); 
     } 
    } 
} 
관련 문제