Add from select value but read only on edit

QuestionsAdd from select value but read only on edit
Alain asked 4 months ago

Hello Abu,

 

I need to have a select value for the add operation, but once set the value must be read only.

 

I tried:

$lstAll = $g->get_dropdown_values( “select xis.item_code as k, xis.item_code as v
from table xis
order by xis.item_code”);
$lstAll = “:;”.$lstAll;
$col = array();
$col[“title”] = “Item”;
$col[“name”] = “ITEM_CODE”;
$col[“hidden”] = false;
$col[“width”] = “120”;
$col[“fixed”] = true;
$col[“visible”] = “xs+”;
$col[“editable”] = true;                                   ##Will be made editable on Add by option’s hook
$col[“edittype”] = “select”;                             ##Select item from list
$col[“editoptions”] = array(“value”=>$lstAll); ##List all Items
$col[“editrules”] = array(“required”=>true, “readonly”=>true); ##Make it read-only after insert
$col[“default”] = “{ITEM_CODE}”;                 ##Initialize with selected value
$col[“search”] = true;                                   ##Column is searchable
$col[“searchoptions”][“sopt”] = array(“bw”); ##Text search “Begin with…”
$col[“export”] = true;
$col[“autoid”] = false;
$cols[] = $col;

 

It looks to work well, but on edit form the Item field is always the first element of $lstAll and not the current value of ITEM_CODE.

How can I achieve the correct behavior (i.e. add ==> select from list, edit ==> read_only value reflecting the added value)?

 

1 Answers
Abu answered 4 months ago

I think you are missing the formatter property. Try setting:

$col["formatter"] = "select";

Your Answer

1 + 13 =

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?