Dropdown widget brings the latest vector item to edit the item datatable

22 views
Skip to first unread message

Anderson Florencio

unread,
Dec 14, 2015, 11:46:23 AM12/14/15
to ZnetDK
Hello, I do not know if this is a bug, but when I use a dropdown widget that is not a required field, by clicking on an item in the datatable and edit it, if the value of the dropdown field of the selected item is null, the dropdown selects the last item in the list that was loaded in the dropdown widget.
Workaround added another item to void the final value of the loaded list.

Pascal Martinez

unread,
Dec 14, 2015, 4:26:22 PM12/14/15
to zne...@googlegroups.com
Hello Anderson,

I confirm you that the last item of the dropdown widget is selected when a null value is specified for selecting one of its items.
This is the behaviour of the puidropdown selectValue method in its version 1.1.

As a workaround, you can test if the value is null from your DAO or your action controller and replace it by an underscore ("_"). Next, add the "data-zdk-noselection" attribute to your zdkdropdow widget, for setting a default item for no selection. For example "Select a value...".

Here is an example below to illustrate the solution:

<form id="myform" class="zdk-form">
   
<label>Dropdown</label>
   
<select class="zdk-dropdown" name="mypuidropdown"
           
data-zdk-noselection="Select a value..." data-zdk-action="mycontroller:myaction">
   
</select>
 
<button class="zdk-bt-refresh" type="button">Init</button>
</form>


<script>
    $
(function () {
 $
('#myform button').click(function () {
            $
('#myform .zdk-dropdown').zdkform('init',{mypuidropdown:'_'});
       
});
   
});
</script>


Hoping that it will be helpfull,

Pascal MARTINEZ

Anderson Florencio

unread,
Dec 15, 2015, 8:20:15 AM12/15/15
to ZnetDK
Hello Pascal, solved the problem. thank you

Pascal Martinez

unread,
Dec 15, 2015, 5:05:18 PM12/15/15
to ZnetDK
Well done!

Pascal MARTINEZ
Reply all
Reply to author
Forward
0 new messages