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

ext_GridPanel2_三

热度:237   发布时间:2013-11-22 23:06:19.0
ext_GridPanel2_3
	//Proxy
	var proxy = new Ext.data.MemoryProxy(data);
	
	//Record 定义记录结果
	var Human = Ext.data.Record.create([
	   {name: "Name", type: "string", mapping: "name"},
	   {name: "Sex", type: "string", mapping: "sex"},
	   {name: "Birthday", type: "string", mapping: "birthday"},
	   {name: "Education", type: "string", mapping: "edu"},
	   {name: "Memo", type: "string", mapping: "memo"}
	]);
	
	//Reader
	var reader = new Ext.data.JsonReader({}, Human);
	
	//store
	var store = new Ext.data.Store({
		proxy: proxy,
		reader: reader
	});
	store.load();
	
	
	
	var grid = new Ext.grid.GridPanel({
		title: "中国公民",
		width: 700,
		autoHeight: true,
		cm: cm,
		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); //必须保留原来的,否则效果无法实现
					 }
				 }
			 }
		 }
		 
		]
	});
});
*/
?
  相关解决方案