2012-05-29 4 views
2

나는 EditorGridPanel을 가지고 있으며, 그리드의 ColumnModel에는 TextField, ComboBox 및 CheckBox가 포함되어 있습니다. TextField 또는 ComboBox를 편집 한 후 편집 된 필드에 대한 세부 정보가 들어있는 "afteredit"이벤트가 시작됩니다. CheckBox 필드를 선택/선택 취소 할 때 어떤 CheckBox가 눌려 졌는지에 대한 세부 정보를 제공하는 이벤트가 없습니다.그리드의 CheckBox를 검사하여 세부 사항을 얻는 방법은 무엇입니까?

+0

roweditor 또는 celleditor를 사용하고 계십니까? – Geronimo

답변

3

선택 모델은 확인란의 열을 렌더링하여 그리드의 행을 선택하거나 선택 취소 할 수 있습니다.

확인란 선택 모델에서 리스너를 적용 해보십시오.

문서는 : Ext.selection.CheckboxModel-event-selectionchange

은 참조 : example

+0

CheckboxSelectionModel에는 텍스트 헤더가 없으며 그리드 열의 특정 위치에 배치 할 수 없습니다. –

+0

체크 박스 열 위치를 설정하려면'injectCheckbox : Number/Boolean/String'을 설정하십시오. http://docs.sencha.com/ext-js/4-0/#!/api/Ext.selection.CheckboxModel-cfg-injectCheckbox – MMT

+0

extjs 2.2 사용 :/injectCheckbox 속성이 없습니다 –

1

Ext.ux.CheckColumn에서 checkchange 이벤트를 사용합니다. RowIndex가 제공됩니다.

편집

는 2.2에 더 많은 발전을하고 있다면 당신이 업그레이드하는 것이 좋습니다 것입니다. 그러나 할 수 없다면 언제든지 덮어 쓰기를 추가하거나 Ext.ux.CheckColumn을 확장하여 최신 버전 이벤트를 포함시킬 수 있습니다. 이 코드는 2.2와 호환되도록 조정해야하지만, 여기에 필요한 이벤트를 포함하는 재정의 예제가 있습니다. 2.2에 Ext.override 메서드가 있다면 잘 모르겠습니다. 귀하의 문서를 확인하십시오 (checkchange 코드는 4.1 API에서 바로 제공됩니다) :

Ext.override(Ext.ux.CheckChange, { 
    constructor: function() { 
     this.addEvents(
      /** 
      * @event beforecheckchange 
      * Fires when before checked state of a row changes. 
      * The change may be vetoed by returning `false` from a listener. 
      * @param {Ext.ux.CheckColumn} this CheckColumn 
      * @param {Number} rowIndex The row index 
      * @param {Boolean} checked True if the box is to be checked 
      */ 
      'beforecheckchange', 
      /** 
      * @event checkchange 
      * Fires when the checked state of a row changes 
      * @param {Ext.ux.CheckColumn} this CheckColumn 
      * @param {Number} rowIndex The row index 
      * @param {Boolean} checked True if the box is now checked 
      */ 
      'checkchange' 
     ); 
     this.callParent(arguments); 
    }, 

    /** 
    * @private 
    * Process and refire events routed from the GridView's processEvent method. 
    */ 
    processEvent: function(type, view, cell, recordIndex, cellIndex, e) { 
     var me = this, 
      key = type === 'keydown' && e.getKey(), 
      mousedown = type == 'mousedown'; 

     if (mousedown || (key == e.ENTER || key == e.SPACE)) { 
      var record = view.panel.store.getAt(recordIndex), 
       dataIndex = me.dataIndex, 
       checked = !record.get(dataIndex); 

      // Allow apps to hook beforecheckchange 
      if (me.fireEvent('beforecheckchange', me, recordIndex, checked) !== false) { 
       record.set(dataIndex, checked); 
       me.fireEvent('checkchange', me, recordIndex, checked); 

       // Mousedown on the now nonexistent cell causes the view to blur, so stop it continuing. 
       if (mousedown) { 
        e.stopEvent(); 
       } 

       // Selection will not proceed after this because of the DOM update caused by the record modification 
       // Invoke the SelectionModel unless configured not to do so 
       if (!me.stopSelection) { 
        view.selModel.selectByPosition({ 
         row: recordIndex, 
         column: cellIndex 
        }); 
       } 

       // Prevent the view from propagating the event to the selection model - we have done that job. 
       return false; 
      } else { 
       // Prevent the view from propagating the event to the selection model if configured to do so. 
       return !me.stopSelection; 
      } 
     } else { 
      return me.callParent(arguments); 
     } 
    }, 
}); 
+0

extjs 2.2를 사용하고 Ext.ux.CheckColumn에 "checkchange"이벤트가 없습니다. –

관련 문제