Dear Sir/Madam,
Refer to http://www.phpgrid.org/docs/#column-options, the Edit Rules, is the <script> a javascript or php script? If php script, why using the <script>… </script>. If javascript, why it is coded in php script?
$col["editrules"] = array("custom"=>true,
"custom_func"=>"function(val,label){return my_validation(val,label);}");
<script>
function my_validation(value,label)
{
if (value < 100)
return [true,""];
else
return [false,label+" should be less than 100"];
}
</script>
Hello,
It's basically javascript, and it is used in PHP (as text string) to invoke at proper place inside library.
Hi,
similar before example. But I want three element. How can I to send data field (val2)?.
$col = array();
$col["title"] = "buy"; //this is val2
$col["name"] = "buy";
$col["width"] = "10";
$col["align"] = "right"; // this column is not editable
$col["search"] = false; // this column is not searchable
$cols[] = $col;
$col = array();
$col["title"] = "total";
$col["name"] = "total";
$col["width"] = "10";
$col["align"] = "right";
$col["search"] = false;
$col["editable"] = true;
$col["editrules"] = array("custom"=>true,
"custom_func"=>"function(val,val2,label){return my_validation(val,val2,label);}");
$cols[] = $col;
<script>
function my_validation(value,value2,label)
{
if (value < value2) // if (value < 100) *****
return [true,""];
else
return [false,label+" should be less than 100"];
}
</script>