-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have list of User objects and I want to output them in Grid with editable inputs like this
<grid model="@load(vm.users)">
<columns>
<column label="Login" width="250px"/>
<column label="Name" width="300px"/>
<column label="Active" hflex="min"/>
<column label=" " hflex="min"/>
</columns>
<template name="model" var="user">
<row >
<textbox value="@load(user.login) @save(user.login, before='save') @validator(vm.loginValidator)" hflex="1" />
<textbox value="@load(user.person.fullName)"/>
<checkbox checked="@bind(user.enabled)"/>
<toolbarbutton label="Save" onClick="@command('save', user=user)"/>
</row>
</template>
</grid>
The first column has textbox with validator and the last one has button Save. The problems is when I press Save button in current row, the validator is called textboxes in every row. I need it to be called to the textbox in the same row as pressed Save button. How can I do it?
To trigger them separately, you will need to make separate command names. A decent option to do that automatically would be to append either the row index, or the user ID to both the @save and the @command in your template.
most likely the easiest will be with EL expressions
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<textbox value="@load(user.login) @save(user.login, before=c:cat('save',user.id)) @validator(vm.loginValidator)" hflex="1" />
...
<toolbarbutton label="Save" onClick="@command(c:cat('save',user.id), user=user)"/>
Asked: 2020-10-30 17:54:44 +0800
Seen: 4 times
Last updated: Oct 30 '20
Validator. Retrieve command arguments
Not send parameters via command from native table. MVVM
Iterate through (Hash)Map in grid using MVVM approach
How to stop combining commands in an ajax call ?
Use parameters in a conditional @command
key event listener for whole page
event.stopPropagation in MinimizeEvent not working in zk 7.0.1