0

select item listbox

asked 2016-09-01 08:16:41 +0800

vsansone gravatar image vsansone
1 1

HI,

I have a question on listbox. I have declared listbox like that:

<listbox id="left" mold="paging" pageSize="4" 
   width="100%" oddRowSclass="non-odd"
   model="@load(vm.elements)"
   selectedItem="@save(vm.element)"
   onSelect="@command('modifyElement')">

when user select a list's element, this is save in "element" object and it's load in a form to modify element. When element is modify in form, I see that change the property on listbox.

I want to know there's a way to modify an element select from listbox without modify the property show in the listbox.

Thank's.

delete flag offensive retag edit

4 Answers

Sort by ยป oldest newest most voted
0

answered 2016-09-01 09:31:50 +0800

Darksu gravatar image Darksu
1976 1 4

Hello vsansone,

You do not want to show the changes on the ui, so do not use notify change on your model.

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2016-09-06 15:05:49 +0800

vsansone gravatar image vsansone
1 1

Hi Darksu,

I think it's not a problem of notify change.

When I modify element in form, at the same time change properties in listbox. I think that element is pass-by-reference. Is there a way to pass element by-value? Or Must I define a new element with item's properties selected?

link publish delete flag offensive edit
0

answered 2016-09-06 18:05:37 +0800

Darksu gravatar image Darksu
1976 1 4

Hello vsansone,

For more information on collection and selection for mvvm please read the following:

http://books.zkoss.org/zk-mvvm-book/8.0/databinding/collectionand_selection.html

To answer your question, you do not have to create a new element, but just use the updated model.

Also it is not clear what you want to achieve with the following code:

onSelect="@command('modifyElement')"

Since the following selectedItem="@save(vm.element)" selects the object, and you can perform any operations there.

Let me know your thoughts.

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2016-09-07 07:27:55 +0800

vsansone gravatar image vsansone
1 1

Hello Darksu,

At first I want to thank you for your answers.

'onSelect' invoke a method to enable form and 'selectedItem' select element that's uploaded in the form. The problem is after, when I modify element in form, because listbox elements properties changes at the same time. I would like to maintain unchanged the elements of the list (@load(vm.elements)).

vsansone

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2016-09-01 08:16:41 +0800

Seen: 40 times

Last updated: Sep 07 '16