代码如下:
colModel: [
{name: 'radiokey', 10,align:'center'},
{name: 'templatekey', key: true, 75,align:'center'},
{name: 'templatename', 150, editable: true,align:'center'},
],
gridComplete:function(){
var ids = jQuery("#jqGrid").jqGrid('getDataIDs');
//单选按钮
for (var i = 0; i < ids.length; i++) {
var cl = ids[i];
var ret = jQuery("#jqGrid").jqGrid('getRowData', cl);
bnEdt = "<input type='radio' name='myname' value='" + ret.templatekey + "'onclick='setmyval(" + cl + ");' />";
jQuery("#jqGrid").jqGrid('setRowData', cl, {
radiokey: bnEdt
});
}
},
onSelectRow: function(rowid){
var radios = $($(this)[0]).find("input[name='myname']");
for(var i=0;i<radios.length;i++){
if(radios[i].value==rowid){
radios[i].checked = true;
break;
}
}
}
function setmyval(id){
radiokey = id;
$("#jqGrid").setSelection(id);
}
参考来源:http://www.xuebuyuan.com/2120822.html