2011-03-31 3 views
0

Ext.OnReady 함수에서로드 된 저장소에서 가져온 항목으로 checkboxgroup을 구성합니다. 이 체크 박스 그룹을 formpanel에 추가하고 add() 호출에서이 오류를 얻으려고합니다. 'events'는 null이거나 객체가 아닙니다. 여기 체크 박스 그룹을 동적으로 formpanel에 추가하기

내가 함께 노력하고 코드 ..

Ext.onReady(function() { 
{ 
    store.each(function (record) { 
     var itemID = record.get('itemID') 
     var itemDesc = record.get('itemDesc'); 
     jsonDataArray.push([itemID,itemDesc]); 
    }); 

    myCheckboxGroup = new Ext.form.CheckboxGroup({ 
     id: 'chk1', 
     xtype: 'checkboxgroup', 
     width: 520, 
     border: true, 
     items: jsonDataArray 
    }); 

    myForm.add(myCheckboxGroup); 
    myForm.doLayout(); 
} 

var myForm = new Ext.form.FormPanel({ 
    id: 'myForm', 
      region: 'center', 
      border: true, 
      autoHeight: true, 
      items: myCheckboxGroup 

}); 
+0

데모 당신이 코드의 서식을하시기 바랍니다 밖으로 정렬 수 있을까요? 무슨 일이 일어 났는지 말하기는 어렵지만 JavaScript가 유효하지 않은 것처럼 보입니다. – Craig

답변

1

당신은 몇 가지 체크 박스 렌더링 당신의 그룹을 제공하고 있는지 확인, 레이아웃 매니저에 의해 만들어진 모든 것을 가지도록하기 위해 xtype을 사용하여 레이아웃 유형을 정의하다 귀하의 양식. 이 양식을 다른 창 (창과 같이)에 넣거나 페이지 본문으로 렌더링해야 할 수도 있습니다.

var myForm = new Ext.form.FormPanel(
{ 
    id:  'myForm', 
    region: 'center', 
    layout: 'form', 
    border: true, 
    autoHeight: true, 
    items: [{ 
     id: 'chk1', 
     xtype: 'checkboxgroup', 
     width: 520, 
     border: true, 
     items: [ 
      {boxLabel: 'Item 1', name: 'cb-1'}, 
      {boxLabel: 'Item 2', name: 'cb-2', checked: true}, // checked 
      {boxLabel: 'Item 3', name: 'cb-3'}, 
     ] 
    }] 
}); 

이제 'items'코드를 JSON 버전으로 바꾸십시오. 시도하기 전에 Ajax 호출에서 리턴하고 응답을 JSON으로 변환했는지 확인하십시오.

자세한 내용은이 주제에 대한 포럼 스레드를 참조하십시오 : ExtJs Forum Thread

0
new Ext.form.FormPanel({ 
    title: 'Test Form', 
    labelWidth: 120, 
    width: 350, 
    padding: 10, 
    tbar: [{ 
     text: 'Add CheckboxGroup', 
     handler: function() { 
      formPanel.add({ 
       xtype: 'checkboxgroup', 
       fieldLabel: 'My CheckboxGroup', 
       columns: 1, 
       items: items 
      }); 
      formPanel.doLayout(); 
      this.disable(); 
     } 
    }], 
    items: comboBox, 
    renderTo: 'output' 
}); 

여기 http://ext4all.com/post/extjs-3-add-a-checkboxgroup-dynamically-to-a-form

관련 문제