0

zk tree on select check childs mvvm

asked 2014-10-31 12:51:02 +0800

fiendnet gravatar image fiendnet
8 1

in the my project i have one tree with multiple selection. the project is implimented by MVVM. i want to when we selecting the parent, the childs at all levels going to checked. my zk version is 7.0.3 the partial-selection-in-tree-view-with-checkbox didn't work. even i changed the styles to zk 7 like .z-treerow-img-checkbox to .z-treerow-checkable and z-treerow-seld to z-treerow-selected. note: i don't want semi-selected, i want the childs checked reality selected and they come in selected items.

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2014-11-06 06:46:46 +0800

cor3000 gravatar image cor3000
6280 2 7

Here a very simple zkfiddle where addToSelection works when used/implemented correctly as in DefaultTreeModel.

No need to use the add/removeSelectionPath methods.

Can you spot what you are doing differently, or update the example to match your case, so I can have a look.

link publish delete flag offensive edit
0

answered 2014-11-03 08:59:09 +0800

cor3000 gravatar image cor3000
6280 2 7

updated 2014-11-03 09:02:18 +0800

when using MVVM you'll likely use a TreeModel implementation. If it implements the Selectable interface (DefaultTreeModel and AbstractTreeModel do this already) you just need to add the children to the selection whenever one node is selected.

see: http://www.zkoss.org/javadoc/7.0.2/zk/org/zkoss/zul/AbstractTreeModel.html#addToSelection(E)

or at a lower level you can implement the TreeSelectableModel interface.

Robert

link publish delete flag offensive edit
0

answered 2014-11-05 15:48:38 +0800

fiendnet gravatar image fiendnet
8 1

thanks robert. it works. but not the addtoselection , i implimented addSelectionPath. now my problems is, when the node unchecked the childs at all levels uncheck. removeSelectionPath does not fires.

link publish delete flag offensive edit

Comments

removeSelectionPath() is not an event listener it is a method you have to call yourself if you want to remove a selection

cor3000 ( 2014-11-06 02:14:15 +0800 )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
3 followers

RSS

Stats

Asked: 2014-10-31 12:51:02 +0800

Seen: 25 times

Last updated: Nov 06 '14

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