How to set the select2 field to readonly or selectable by condition?for example,
$("#x_local").val().on("change focusout", function() {
if ($("#x_local").val() == 1) {
// test on below format 1 by 1 (not all together)
// {field_var} like $("#x_country"), $("#el_{table}_country")
$("{field_var}").attr('readonly', 'readonly');
$("{field_var}").attr('readonly', true);
$("{field_var}").attr('disabled', true);
$("{field_var}").attr('enable', false);
$("{field_var}").prop('readonly', true);
$("{field_var}").prop('disabled', true);
$("{field_var}").prop('enable', false);
} else {
$("{field_var}").removeAttr('readonly');
$("{field_var}").prop('readonly', false);
$("{field_var}").prop('disabled', false);
$("{field_var}").prop('enable', true);
}
});
Some of them are able to make the field readonly. But when try to enable back, the lookup condition is GONE.What should be the correct way to make it work?TIA
This code will make the field disable. (Great)But when click Add (save), it prompt
Please enter required field - TrademarkSeems the Trademark value is reset to blank/null.Any suggestion?
You may add your code in > Row_Inserting > server event to assign the field
value with your default value.
This is a select field, no default value. I’m doing a conditional ‘disabled’ for this field.Or I need to create a temporary array / or temporary element as array (currently 4 select fields) to keep those values?
[quote=arbei post_id=169566 time=1642063195 user_id=84879]
You should remove .select2().
[/quote]I’m looking for readonly features.if the .select2() removed, user can re-select a new value. This is not what I want.At least with the .select2(), user cannot select any new value.
The condition is set to… after any one of the amount field changed, some of the reference field might not be able to change.another way is to create a new ajax to filter select data only return the value being selected… or any good suggestion?