当我尝试选中 jQgrid 中的复选框时,它选择了很好的值,并且我有自定义格式化程序文本字段而没有在文本字段中输入值并尝试选中该复选框,之后我将显示警报消息我将取消选中该复选框,但焦点不会从网格中删除。
我已附上屏幕截图,请告诉我答案。
代码粘贴在这里:
jQuery("#list1").jqGrid({
url:actionurl,
mtype: 'POST',
colNames:['PartnerId', 'Employee No','Employee Name' ,'Position', 'Position Id', 'Wages','Relieve Date','Days Required'],
colModel:[
{name:'partnerId',index:'partnerId', width:280,sortable:true,search:false, hidden: true},
{name:'em_ka003_employeeno',index:'em_ka003_employeeno', width:200,sortable:true},
{name:'empname',index:'empname', width:280,sortable:false,search:false},
{name:'position',index:'position', width:250,sortable:false,search:false},
{name:'positionId',index:'positionId', width:0,sortable:false,search:false,hidden:true},
{name:'wages',index:'wages', width:100,sortable:false,search:false},
{name:'emp_relievedate',index:'emp_relievedate', width:200,sortable:false,search:false},
{name:'daysrequired',index:'daysrequired', width:140,sortable:false,search:false,formatter:createText},
],
rowNum:10,
rowList:[5,10,15],
pager: '#pager1',
sortorder: "asc",
sortname: 'em_ka003_employeeno',
viewrecords: true,
rownumbers: true,
loadonce: false,
forceFit: true,
datatype: 'xml',
multiselect: true ,
footerrow:true,
userDataOnFooter:true,
onSelectRow: function(rowId)
{
handleSelectedRow(rowId);
},
caption: "<b>Labor Extension",
gridComplete: function() {
$.unblockUI();
}
});
这是我的自定义格式化程序功能:
function createText(el, cellval, opts)
{
return "<span><input class='dojoValidateValid required TextBox_OneCell_width number' type='text' id='days_req"+cellval.rowId+"' name='days_req"+cellval.rowId+"' onKeyPress='return checkIt(event,false)'/></span>";
}
function handleSelectedRow(id)
{
var jqgcell = jQuery('#list1').getCell(id, 'partnerId');
var daysrequired = jQuery("#days_req"+id+"").val();
var cbIsChecked = (jQuery("#jqg_list1_"+jqgcell).attr('checked'));
if(cbIsChecked==true)
{
/* Append the Days Required */
if(daysrequired=="")
{
alert("please enter the extension days");
jQuery("#days_req"+id+"").focus();
jQuery("#jqg_list1_"+jqgcell).attr('checked', false);
jQuery('#list1').restoreRow(id);
return false;
}
}