You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected Behavior
When a field contains an array as its value and is updated, the value returned by editValue should be presented to update_item in the same form.
For example, let's say we have an item that looks like this: {"fruits": ["apple", "banana"]}. Let's say that we edit the item such that the fruits field should only contain ["apple"]. In other words, editValue returns ["apple"]. Then, we would expect update_item to receive the argument {"fruits": ["apple"]}.
Actual Behavior
The value returned by editValue is corrupted before being passed to update_item.
In the example above, editValue returns ["apple"], but update_item receives {"fruits": ["apple", "banana"]}.
Because of the true in this call, jQuery performs the extend operation recursively. To fix this bug, we should make this extend non-recursive by changing the line to:
It looks, based on the Travis CI checks, that this may be a feature rather than a bug. Is that the case? If so, is there any way to change a field's value from [1, 2] to [1] under the current release of jsGrid?
My intuition is that, by default, the $.extend() should not be recursive, and that if a user really needs their new field value to be extended from the old value, they should save the old value as a property of this in editTemplate and then perform the extend in editValue. This would allow users who want the extend functionality to build what they want, and it would also me to achieve the functionality I was hoping for.
Expected Behavior
When a field contains an array as its value and is updated, the value returned by
editValue
should be presented toupdate_item
in the same form.For example, let's say we have an item that looks like this:
{"fruits": ["apple", "banana"]}
. Let's say that we edit the item such that the fruits field should only contain["apple"]
. In other words,editValue
returns["apple"]
. Then, we would expectupdate_item
to receive the argument{"fruits": ["apple"]}
.Actual Behavior
The value returned by
editValue
is corrupted before being passed toupdate_item
.In the example above,
editValue
returns["apple"]
, butupdate_item
receives{"fruits": ["apple", "banana"]}
.Steps to Reproduce
https://jsfiddle.net/jnooq68m/1/
editValue
returns [1], the new value is set to [1, 2, 3].Steps to Fix
This problem is occurring because of line 1444 in jsgrid.core.js (as of commit f521a20).
Because of the
true
in this call, jQuery performs the extend operation recursively. To fix this bug, we should make this extend non-recursive by changing the line to:A similar change must also be made on line 1455.
The text was updated successfully, but these errors were encountered: