0

populate list when clicking on other grid row cell button

asked 2014-12-16 06:17:12 +0800

syeligeti gravatar image syeligeti
1

updated 2014-12-16 06:26:36 +0800

Hi,

I am new to ZK framework. I have two grids in same zul file. When ever i click on first grid row cell button then i need to populate other grid.

 For this i have written viewmodel, when ever i click on button am calling viewmodel notifyChange event and written business logic to get details of list to populate other grid. But the list of object while accessing in zul file am not able to get value.

zul file
first grid contains button in row
------------------
<window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('com.hm.controller.CountryViewModel')">
<listbox vflex="true" hflex="1"  model="@load(vm.countryData.countries)">
    <auxhead>
        <auxheader colspan="6" class="topic">Country List</auxheader>
    </auxhead>
    <listhead>
        <listheader label="Country Name" align="center" />
        <listheader label="Country Code" align="center" />
    </listhead>
    <template name="model" var="country">
        <listitem>
            <listcell>
                <hbox> 
                    <button label="@load(country.countryName)" onClick="@command('countryDetails', countryId=country.countryId)"/>
                </hbox>
            </listcell>     
            <listcell label="@load(country.code)" />
        </listitem>
    </template>
</listbox>

viewmodel business logic
----------------------------
@Command
@NotifyChange("countryDetails")
public List<State> countryDetails(@BindingParam("countryId") int countryId) {
    List<State> states = new CountryDaoImpl().getStates(countryId);
    return states;
}

second grid in same zul file
---------------------
<grid model="${states}" emptyMessage="Nothing in Domain" height="400px">
    <columns sclass="tableDataHeading">
        <column label="state Name" sclass="w10"/>
        <column label="code" sclass="w20"/>
    </columns>
    <template name="model" var="state">
        <row>
            <label value="${state.stateName}"/>
            <label value="${state.code}"/>
        </row>
    </template>
</grid>


Please suggest me on this.

Thanks,
Sreedhar
delete flag offensive retag edit

Comments

Thanks for reply. I have followed as per your suggestion. But still am getting states list value as empty in zul file. Please Can you help me on this issue.

syeligeti ( 2014-12-18 05:22:06 +0800 )edit

In the command, you should notify change states instead of countryDetails. And the grid model should be @load(vm.states) instead of EL ${states}.

vincentjian ( 2015-01-20 06:42:24 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-12-16 08:33:31 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/
@Command
@NotifyChange("countryDetails")
public List<State> countryDetails(@BindingParam("countryId") int countryId) {
    List<State> states = new CountryDaoImpl().getStates(countryId);

    // Notify all dependent properties.
    BindUtils.postNotifyChange(null, null, CountryViewModel.this, "*");

    or:

    // Notify one dependent property.
    BindUtils.postNotifyChange(null, null, CountryViewModel.this, "states");



    return states;
}
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: 2014-12-16 06:17:12 +0800

Seen: 26 times

Last updated: Dec 16 '14

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