Want to change data for readonly field.

QuestionsWant to change data for readonly field.
Anand asked 8 years ago

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

4 Answers
Abu Ghufran answered 8 years ago

Hello,

Please share your code for review. I'll be replying back with possible fix.
You can share using pastebin.com

Anand answered 8 years ago

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>

Anand answered 8 years ago

Hi Abu,

Waiting for your reply…

Abu Ghufran answered 8 years ago

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" … >

Your Answer

12 + 18 =

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?