Hello,
There is a bug in DynamicForm component.
If DynamicForm contains a field which is a SelectItem with additional properties:
{
required: false,
allowEmptyValue: true,
emptyDisplayValue: "Select..."
redrawOnChange: true // <- critical
}
and is bound to DataSource, then that field`s value is not sent to server if value is NULL.
Scenario:
When record has a selected value "123"
Then If it`s changed to empty option "Select.."
On action save that field is not sent to server ( DynamicForm.values do not contain that field)
if "redrawOnChange" is false everything works as expected (DynamicForm.values contains a field with value NULL)
Thought that I could set defaultValue thru "defaultValue" property, but it`s impossible to have NULL.
Why this happens:
FormItem is redrawn after change, so method FormItem.redrawn is called, this method calls a method
FormItem._showValueAfterDraw(true);
And clearValue() will call DataBoundComponent._performActionOnValue for action "clear" which removes that field from DynamicForm.values;
As a consequence all fields which are "null" are removed from DynamicForm.values, as I said this happens only if redraw occurs.
Could you suggest how to workaround this?
Thanks.
affected versions: all
browsers: all
tested on: SmartClient_v100p_2014-12-22_LGPL.zip
There is a bug in DynamicForm component.
If DynamicForm contains a field which is a SelectItem with additional properties:
{
required: false,
allowEmptyValue: true,
emptyDisplayValue: "Select..."
redrawOnChange: true // <- critical
}
and is bound to DataSource, then that field`s value is not sent to server if value is NULL.
Scenario:
When record has a selected value "123"
Then If it`s changed to empty option "Select.."
On action save that field is not sent to server ( DynamicForm.values do not contain that field)
if "redrawOnChange" is false everything works as expected (DynamicForm.values contains a field with value NULL)
Thought that I could set defaultValue thru "defaultValue" property, but it`s impossible to have NULL.
Why this happens:
FormItem is redrawn after change, so method FormItem.redrawn is called, this method calls a method
FormItem._showValueAfterDraw(true);
Code:
_showValueAfterDraw : function (redrawing) {
// If we're empty, explicitly clearValue() to re-evaluate default value
// Otherwise just show our current value.
if (this.isSetToDefaultValue() || (this._value == null)) this.clearValue(); // <- here clearing is triggered.
else this._showValue(this._value, redrawing);
},
As a consequence all fields which are "null" are removed from DynamicForm.values, as I said this happens only if redraw occurs.
Could you suggest how to workaround this?
Thanks.
affected versions: all
browsers: all
tested on: SmartClient_v100p_2014-12-22_LGPL.zip
Comment