2011-11-18 5 views
0

격자 패널을 만들고 각 행에 이벤트를 첨부하려고합니다. 다음은 내 코드입니다extjs rowselect가 작동하지 않습니다.

var locationdata = Ext.create('Ext.data.Store', { 
    fields:['name'], 
    storeId:'simpsonsStore', 
    data:{'items':[ 
       { 'name': 'Lisa'} 
      ]}, 
     proxy: { 
      type: 'memory', 
      reader: { 
       type: 'json', 
       root: 'items' 
      } 
     } 

}); 

hintBox = Ext.create('Ext.grid.Panel', { 
    title: 'Location List', 
    store: locationdata, 
    columns: [ 
     { header: 'Name', dataIndex: 'name' , flex:1 } 
    ], 
    flex: 5 
}); 
hintBox.getSelectionModel().on('rowselect', function(sm, rowIdx, r) { 
    alert("row selected"); 
}); 

본문으로 렌더링되는 패널에 hintBox를 추가 할 예정입니다.

이 코드에 어떤 문제가 있습니까?

답변

1

선택 모델에는 'rowselect'이벤트가 없습니다. Extjs 4 선택 모델에는 selectchange 이벤트 만 있습니다.

hintBox.getSelectionModel().on('selectionchange', function(sm, selectedRows, opts) { 
     //selected rows is an array of models and if you want just one row selected, 
     //you have to config the grid so it only accepts one selection i think is selType: 'SINGLE' or 'SIMPLE' 
     // and after that selectedRows[0] will be the selected row 
     alert("rows selected"); 
}); 
관련 문제