0

MVVM programmatically component binding

asked 2022-10-21 01:46:54 +0800

alefus gravatar image alefus
1 1

updated 2022-10-21 01:52:54 +0800

Hi, I create programmatically a grid:

...

private void createRow(Rows rows) {
    for (Content c : data) {
        Row row = new Row();
        row.setParent(rows);
        Label label = new Label(c.getId());
        label.setParent(row);
        Textbox textbox = new Textbox(c.getValue());
        textbox.setParent(row);
    }
}

...

I need to create programmatically a binding like this:

<textbox value="@bind(each.value)"/>

in order to retrieve the value in the textbox.

Thank you.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-10-24 15:31:12 +0800

MDuchemin gravatar image MDuchemin
2298 1 5
ZK Team

Hey there

Creating the components manually in this way is usually more of an MVC than MVVM option, however...

Since you are creating the components from Java side, you don't need the databindings to retrieve the values.

You can just do textbox.addEventListener to add an onChange event listener to your textbox, which will trigger when the user types in something. That event will have access to the data and underlying component, so you can retrieve the new value from it.

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: 2022-10-21 01:46:54 +0800

Seen: 6 times

Last updated: Oct 24

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