extjs怎么往grid的每个cell中添加 radio单选按钮

时间:2022-08-24 11:39:14
 首先先编写 function。返回 <input>的标签,注意 type='radio'然后在grid的cm中定义 renderer  
function showEdit(name) {
var record=store.getRange();
var cmp=record[index].get('status_num');
if(index<record.length)
index++;
if(index>=record.length)
index=0;
return "<input name='"+index+"' type='radio' value='1' "+(cmp==1?"checked='checked'":"")+">未打卡</input> "
+"<input name='"+index+"' type='radio' value='2' "+(cmp==2?"checked='checked'":"")+">已到</input> "
+"<input name='"+index+"' type='radio' value='3'"+(cmp==3?"checked='checked'":"")+">迟到</input> "
+"<input name='"+index+"' type='radio' value='4'"+(cmp==4?"checked='checked'":"")+">早退</input> "
+"<input name='"+index+"' type='radio' value='5'"+(cmp==5?"checked='checked'":"")+">缺席</input> "
+"<input name='"+index+"' type='radio' value='5'"+(cmp==6?"checked='checked'":"")+">请假</input> ";

};


 

var grid = new Ext.grid.EditorGridPanel({
id : 'gird',
title : '考勤项目信息列表',
region : 'center',
stripeRows : true,
autoScroll : true,
loadMask : true,
store : store,
clicksToEdit: 1,
frame: true,
cm : new Ext.grid.ColumnModel({
defaults: {
sortable: true // columns are not sortable by default
},
columns : [
{
header : '序号',
dataIndex : 'id',
width : 100
},
{
header : '学号/工号',
dataIndex : 'people_id',
width : 100
},
{
header : '姓名',
dataIndex : 'people_name',
width : 100
},
{
header : '考勤状态',
dataIndex:'status_num',
width : 250,
renderer : showEdit
}
]
}),

//tbar : toolbar
})