带Checkbox的EditorGridPanel

var store,grid,store1;
//这是用DWR读取的数据
//基本上从DB中读到ComboBox的数据都是编码;0,1就是编码
var data = [['小红','1'],['小明','0']];
//编码与名称相对应的数组
var myData = [['0','高级用户'],['1','普通用户']];
//我们要实现:
//1.显示读取的用户的用户类型
//2.用户可以修改用户类型
Ext.onReady(function() {

	//ComboBox所用到的store1
	store1 = new Ext.data.SimpleStore({
	
		fields:['value','text'],
		data:myData
	});
	
	//grid所用到的store
	store = new Ext.data.Store({
	
		proxy:new Ext.data.MemoryProxy(data),
		reader:new Ext.data.ArrayReader({},[
		
			{name:'yhm'},
			{name:'yhlx'}
		])
	});
	store.load();
	
	//Column Mode cm
	var cm = new Ext.grid.ColumnModel([
	
		{header:'用户名',dataIndex:'yhm'},
		{renderer:rendererCombobox,header:'用户类型',dataIndex:'yhlx',editor:
		
			new Ext.grid.GridEditor(
			new Ext.form.ComboBox({
						
						id:'yhlx',
						mode:'local',
						triggerAction:'all',
						store:store1,
						valueField:'value',
						displayField:'text',
						value: 'text'
	        })
		)}
	]);

	//grid
	grid = new Ext.grid.EditorGridPanel({
	
		clickToEdit:1,
		store:store,
		cm:cm,
		renderTo:'gridDiv'
	});
});
//根据Combobox列表中对应的Id的值来渲染 
function rendererCombobox(value, p, r) { 

    var index = store1.find(Ext.getCmp('yhlx').valueField, value); 
    var record = store1.getAt(index); 
  
    if (record == null) { 
        return value; 
    } else { 
        return record.data.text; // 获取record中的数据集中的display字段的值  
    } 
} 

你可能感兴趣的:(function,DWR,header,null)