ZK Framework : Refresh dynamic Layout using foreach

I'm using forEach "myList" to draw elements. Now, when I update data in "myList", my page can not redraw.
I tried use invalidate() but not OK.
Please help me.
Thanks very much.

My code below :

<vlayout id="mainLayout" >
        <groupbox hflex="1" mold="3d" open="${forEachStatus.index==0}" forEach="${vm.myList}">
            <caption label="${each.groupName}" sclass="customIcon">
                <span id="arrow-${forEachStatus.index}" class="open-${forEachStatus.index}" />
            <vlayout hflex="1" spacing="10px">
                <groupbox hflex="1" mold="3d" forEach="${each.listData}" open="false">
                    <caption label="${each.groupName}" sclass="customIcon">

                    <listbox emptyMessage="Empty data" mold="paging" pageSize="10"
                             sizedByContent="true" hflex="1">
                        <!--Listbox content here-->




public void onSearch() {
    try {
        //Business OK here, reload myList OK
    } catch (Exception e) {
        mLogger.error(e.getMessage(), e);



1 answer

  • answered 2018-05-16 06:26 Col

    Without seeing the full code (or at least more of it) it is hard to help. It looks like you are using MVC and MVVM. I recommend sticking to MVVM. Specifically this might be useful.

    Use children in your vlayout to iterate over your myList elements:

    <vlayout children="@load(vm.myList)">
        <template name="children">
            <groupbox hflex="1" mold="3d" open="@load(each.index eq 0)">
                <!-- contents of groupbox here -->

    In your onSearch() method you don't need to invalidate mainLayout. The @NotifyChange("myList") should reload your myList (provided you have a getter method in your ViewModel class)