Hi Abu,
I'm Using two fields From Year and To Year. Here To year is readonly. When I change From Year in its on change I'm changing To year field data. But Its not working. Also When To Year is not readonly Its working correctly.
Thank You
Hello,
Please share your code for review. I'll be replying back with possible fix.
You can share using pastebin.com
Hi Abu,
Here My Code,
GRID CODE:
———-
$col = array();
$col["title"] = "From Year";
$col["name"] = "fromyear";
$col["sortable"] = false; // this column is not sortable
$col["search"] = true;
$col["editable"] = true;
$col["width"] = "40";
$col["edittype"] = "select"; // render as select
$col["editoptions"] = array("value" => "2015:2015;2016:2016;2017:2017;2018:2018;2019:2019;2020:2020","required"=>true,"onchange" => "fromyear_change()");
$col["formatter"] = "select"; // display label, not value
$cols[] = $col;
$col = array();
$col["title"] = "To Year"; // caption of column
$col["name"] = "toyear";
$col["editable"] = true;
$col["editoptions"] = array("required"=>true);
$col["editrules"] = array("readonly"=>true);
$col["width"] = "40";
$col["search"] = false;
$col["isnull"] = true;
$col["align"] = "right";
$cols[] = $col;
SCRIPT:
——-
<script>
function fromyear_change()
{
var fromyear = $('select[name=fromyear]').val();
jQuery('input[name="toyear"]:visible').val(parseFloat(fromyear) + 1);
}
</script>
Change 'to year' options to:
$col["editoptions"] = array("required"=>true,"readonly"=>true);
$col["editrules"] = array();
The editrules readonly shows text instead of readonly field. To show input field while keeping it readonly you need to set it in editoptions.
The editoptions are mapped on input tag attributes. so it will become <input readonly="readonly" … >