When i tried to check the check box in jQgrid it selecting the values that's fine ,and in that i have the custom formatter text field with out entering the values in text field and tried to select the check box i will display the alert message after that i will uncheck the checkbox but the focus is not get removed from the grid.
I have attached the screen shot please let me know the answer.
code is pasted here:
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();
}
});
This is my custom formatter function:
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;
}
}
I got the answer.
If the text field value is zero while selecting the particular row in jqgrid at that time validate that with javascript and uncheck the selected row from the grid.
Here is the working code i pasted below:
if(daysrequired=="0")
{
myGrid.jqGrid('resetSelection');
}
myGrid
is my grid id.resetSelection
is a method in the jQGrid to unselect the selected rows.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With