1.经过一段时间的使用extjs,发现对于行数据的选择是我们使用最多的功能,下面是我这两天使用的几个得到行数据的方法。
(1)grid.getStore().getRange(0,store.getCount()); //得到grid所有的行
(2)grid.getSelectionModel().getSelections(); //得到选择所有行
注:如果不声明var sm = new Ext.grid.CheckboxSelectionModel();则会报此句没有该对象或属性
Var selectRows =grid.getSelectionModel().getSelections();
selectRows[0].get(“gird中某列的dataIndex属性值”) //取选中行记录的某列的值
(3)grid.selModel.selections.items; //得到选择所有行
(4)grid.getSelectionModel().getSelected(); //得到选择行的第一行
(5)//单击gird中某一行时取得该行的数据
demoGrid.on('rowclick', function(demoGrid,rowIndex,event){
var record = demoGrid.getStore().getAt(rowIndex);
alert(record.get('id'));
});
2.在extjs的grid中选中行时,复选框不选中,只有选中点击复选框时才选中,具体怎么实现
var sm = new Ext.grid.CheckboxSelectionModel(); sm.handleMouseDown = Ext.emptyFn;//主要是这句