Hi Guys, I am also quite a newby to jqGrid and need some help please. I need custom validation on a field I am editing.
I looked at the examples and tried the following code below but get the error "Custom function should be present in case of custom checking!". Please help a newbie out!!!
<?php
$grid->SelectCommand = 'SELECT * FROM sms_recipients';
$grid->table = 'sms_recipients';
$grid->dataType = 'json';
$checkNumber = <<<CHECKER
function checkLength(value, colname) {
if (value < 0 && value >20)
return [false,"Please enter value between 0 and 20"];
else
return [true,""];
}
CHECKER;
$Model = array(
array("name"=>"RecipientCellular", "sorttype"=>"number","editrules"=>array("custom"=>true, "custom_func"=>"$checkNumber"), "editable"=>true)
);
$grid->setColModel($Model);
$grid->setUrl('/src/content/grids/recipients/add_recipients.php');
$grid->setGridOptions(array("rowNum"=>grid_num_rows, "rowList"=>$grid_rows, "hoverrows"=>grid_hover, "width"=>grid_width, "height"=>grid_height, "sortname"=>"RecipientSurname"));
$grid->navigator = true;
$grid->setNavOptions('navigator', array("excel"=>false,"add"=>true,"edit"=>true,"del"=>false,"view"=>false, "search"=>false));
$grid->renderGrid('#jqGrid','#pager',true, null, null, true,true);
$conn = null;
?>