Problem with TreeModel and <template> when removing nodes

asked 2013-03-12 07:38:19 +0800

tisaksen gravatar image tisaksen
44 5


I have the a tree which I am displaying with the following zul:

<tree id="salesorderTree" rows="0" width="100%" model="@bind(vm.salesorderTreeModel) @template(not empty each.children ? 'product' : 'detail')">
<treecols sizable="true"> 
    <treecol hflex="24" label="Varelinjer"/>
<template name="product" var="productNode" status="spn">
            <treecell label="@load(productNode.data.description)"/>
<template name="detail" var="detailNode" status="sdn">
            <treecell label="@load(detailNode.data.salesorderDetailId)"/>


This will output a simple tree with this layout:

    product 1
       product detail 
       product detail 
    product 2
       product detail

and so forth.

This is fine but the problem is when I remove all product details on a product I get an error:

Property 'salesorderDetailId' not found on type no.tisaksen.zk.tree.SalesorderProduct Property 'quantity' not found on type no.tisaksen.zk.tree.SalesorderProduct

This means it's actually trying to render the "detail" template when the detail is in fact not there anymore.

Anyone know how to solve this? Or maybe can see what I'm doing wrong?

delete flag offensive retag edit



in you code not empty each.children ? 'product' : 'detail', so if you remove all the children of product then goes to 'detail', doesn't it?you have to has a way to determine the node is a product or not, shouldn't depend on children.

dennis ( 2013-03-12 11:10:31 +0800 )edit

Oh right, I see the problem. Maybe I can just use isLeaf (since these are TreeNode's anyway) so it will be @template(each.leaf ? 'detail' : 'product')

tisaksen ( 2013-03-12 12:22:10 +0800 )edit
Be the first one to answer this question!
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




Asked: 2013-03-12 07:38:19 +0800

Seen: 15 times

Last updated: Mar 12 '13

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