当前位置: 代码迷 >> Web前端 >> ext_GridPanel2_六
  详细解决方案

ext_GridPanel2_六

热度:234   发布时间:2013-11-22 23:06:19.0
ext_GridPanel2_6
	var grid = new Ext.grid.GridPanel({
		title: "中国公民",
		width: 700,
		autoHeight: true,
		cm: cm,
		sm: sm, //指定行选择模型为CheckboxSelectionModel,默认为RowSelectionModel
		store: store,
		renderTo: "a",
		frame: true,
		autoExpandColumn: "memo",
		buttonAlign: "center",
		buttons: [
		 {
			 text: "第一行",
			 handler: function(){
				 var rsm = grid.getSelectionModel(); //得到行选择模型
				 rsm.selectFirstRow();
			 }
		 },
		 {
			 text: "上一行",
			 handler: function(){
				 var rsm = grid.getSelectionModel();
				 if(!rsm.hasPrevious()){
					 Ext.Msg.alert("警告","已经达到第一行");
				 } else {
					 rsm.selectPrevious();
				 }
			 }
		 },
		 {
			 text: "下一行",
			 handler: function(){
				 var rsm = grid.getSelectionModel();
				 if(!rsm.hasNext()){
					 Ext.Msg.alert("警告","已经达到最后一行 ");
				 } else {
					 rsm.selectNext();
				 }
			 }
		 },
		 {
			 text: "最后一行",
			 handler: function(){
				 var rsm = grid.getSelectionModel();
				 rsm.selectLastRow();
			 }
		 },
		 {
			 text: "全选",
			 handler: function(){
				 var rsm = grid.getSelectionModel();
				 rsm.selectAll();
			 }
		 },
		 {
			 text: "全不选",
			 handler: function(){
				 var rsm = grid.getSelectionModel();
				 rsm.deselectRange(0,grid.getView().getRows().length - 1);
			 }
		 },
		 {
			 text: "反选",
			 handler: function(){
				 var rsm = grid.getSelectionModel();
				 for(var i = grid.getView().getRows().length - 1; i >=0; i--){
					 if(rsm.isSelected(i)){
						 rsm.deselectRow(i);
					 } else {
						 rsm.selectRow(i,true); //必须保留原来的,否则效果无法实现
					 }
				 }
			 }
		 }
		 
		]
	});
});
/**
 * Extjs中的复选框是图片做的,不是传统的<input type=checkbox/>标记。如果要实现单选,为行选择模型配置singleSelect: true
 */
?
  相关解决方案