0

How to edit a List of String using a grid

asked 2021-04-10 01:23:32 +0800

RomanZK gravatar image RomanZK
1 1

I have a multi valued field in a grid that I want to be able to edit. This field is represented as a list box in the grid.

To edit it, I want to be able to click on the listbox to launch a dialog. This dialog will receive the list as an input. In this dialog I want to be able to

  1. Add new elements (i.e. String) to the list.
  2. Edit any of the elements.
  3. Delete an element.
  4. Save the list. (including new elements and edited existing elements)

Upon saving, the dialog should close and the List should be updated in the ListBox inside the other grid.

For some unknown reason, I am unable to edit the elements in the list. It is also interesting to note that I stumbled on a code snippet from fiddle. The code on fiddle site does not work. Search "7-How-do-I-edit-a-List-of-String-within-a-listbox-" on fiddle site.

Run it yourself and see. The edit does not work.

My code is similar the only difference is that I am using grid in the pop up dialog for the purpose of the edit.

Any ideas ? when I click on save the pop up dialog closes but I notice that the edits do not save either.

My code snippets below. This is the dialog code.

<window apply="org.zkoss.bind.BindComposer" title="Edit Value" border="normal" position="center,center" viewmodel="@id('vm') @init('com.test.vo.ValueListViewModel')" width="800px" height="500px"> <vlayout> <hlayout>

<button label="Add" onclick="@command('add')"/>
</hlayout> <grid sclass="sidebar" model="@bind(vm.value)"> <columns width="800px"> <column width="400px" label="Value"/> <column width="200px" label="Save"/>
<column width="200px" label="Delete"/>
</columns> <rows> <template name="model">
<row sclass="sidebar-fn"> <textbox value="@bind(each)" width="100px"/>
</row>
</template>
</rows> </grid>
<hbox width="100%" pack="center"> <button label="close" onclick="@command('close')"/> <button label="save" onclick="@command('save') @global-command('valuelistDlgClose',bindVariable=vm.selectedRecord,editedValue=vm.value)"/> </hbox> </vlayout> </window>

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2021-04-12 21:42:52 +0800

RomanZK gravatar image RomanZK
1 1

I am still stuck on this current issue.

I considering implementing the above dialog using mvc instead of mvvm.

link publish delete flag offensive edit

answered 2021-04-13 14:32:30 +0800

hawk gravatar image hawk
2785 1 5
http://hawkphoenix.blogsp... ZK Team

It's the limitation of data binding. Please see Limitation at http://books.zkoss.org/zk-mvvm-book/9.5/databinding/propertybinding.html

You can either use MVC pattern or wrap a value in a bean like <textbox value="@bind(each.value)"/>.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2021-04-10 01:23:32 +0800

Seen: 10 times

Last updated: Apr 13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More