This example shows you how to add validator to grid column. The validator will ensure the input from user is correct before doing data operation task.
In above example, we have used RequiredFieldValidator and RegularExpressionValidator. The RequiredFieldValidator make sure that input from user is not empty. And the RegularExpressionValidator helps to ensure the input for customerNumber is integer.
Together with above two validators, there are other two validators: RangeValidator and CustomValidator, all cover full range of grid input validation.
span style="color: #ff0000;">"/KoolAjax/koolajax.php";
$koolajax->scriptFolder = $KoolControlsFolder."/KoolAjax""/KoolGrid/koolgrid.php"//This $db_con link has been created inside KoolPHPSuite/Resources/runexample.php
$ds->SelectCommand = "select customerNumber as pk, customerNumber,customerName,phone,city from customers""update customers set customerNumber=@customerNumber, customerName='@customerName', phone='@phone', city='@city' where customerNumber=@pk";
$ds->DeleteCommand = "delete from customers where customerNumber=@pk";
$ds->InsertCommand = "insert into customers (customerNumber,customerName,phone,city) values (@customerNumber,'@customerName','@phone','@city');""grid");
$grid->scriptFolder = $KoolControlsFolder."/KoolGrid";
$grid->styleFolder="default""/KoolAjax/loading/5.gif""655px""CustomerNumber";
$column->DataField = "customerNumber";
//Create regular expression validator to make sure the input is an integer.
"/^([0-9])+$/";
$validator->ErrorMessage = "Please input an integer""CustomerName";
$column->DataField = "customerName";
//Add required field validator to make sure the input is not empty.
"Phone";
$column->DataField = "phone";
//Add required field validator to make sure the input is not empty.
"City";
$column->DataField = "city";
//Add required field validator to make sure the input is not empty.
"form1" method="post"'padding-bottom:5px;width:655px;'