edit validation

Questionsedit validation
Man Lam asked 8 years ago

Is it possible to not allow to input value in a particular column if the value of another column contain word "YES" or "UNCERTAIN" in edit mode?

3 Answers
Abu Ghufran answered 8 years ago

You can connect onblur event and in callback function set particular textbox as readonly or editable.

$col["editoptions"] = array("onblur" => "update_field(this)");

<script>
function update_field(o)
{
if ($(o).val() == "YES" || $(o).val() == "UNCERTAIN")
$("#particular_column").attr("disabled","disabled");
else
$("#particular_column").attr("disabled",false);
}
</script>

For inline editing, you will also need to set like:

$("input[name='particular_column'].editable").attr("disabled",false);

Abu Ghufran answered 8 years ago

You can inspect the field id.using firebug and use jquery functions to disable / enable desired field.

To know jquery selector:
http://easycaptures.com/fs/uploaded/1017/9892108434.png
http://easycaptures.com/fs/uploaded/1017/9617668813.png

Man Lam answered 8 years ago

It don't work. pls see my code as below

$col = array();
$col["title"] = "回來時間";
$col["name"] = "in_time";
$col["width"] = "50";
$col["editable"] = true; // this column is editable
$col["editoptions"] = array("size"=>20); // with default display of textbox with size 20
//$col["editrules"] = array("required"=>FALSE); // required:true(false), number:true(false), minValue:val, maxValue:val
$col["editrules"] = array("custom"=>true,"custom_func"=>"function(value, label){return my_validation(value, label);}");
$col["formatter"] = "datetime"; // format as date
$col["formatoptions"] = array("srcformat"=>'H:i:s',"newformat"=>'H:i:s',"opts" => array("timeOnly" => true));
$col["search"] = true;
$cols[] = $col;

$col = array();
$col["title"] = "即日返回公司";
$col["name"] = "back_to_office";
$col["width"] = "50";
$col["search"] = true;
$col["editable"] = true; // this column is not editable
$col["edittype"] = "select";
$col["editoptions"] = array("value"=>'Yes:Yes;No:No;Uncertain:Uncertain', "multiple" => true, "onblur" => "update_field(this)");
$col["align"] = "left"; // this column is not editable
$cols[] = $col;

<script>
function update_field(o)
{
if ($(o).val() == "No" || $(o).val() == "Uncertain")
//$("#in_time").attr("disabled","disabled");
$("input[name='in_time'].editable").attr("disabled",false);
else
$("#in_time").attr("disabled",false);
}
</script>

Your Answer

5 + 5 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?