0

searchbox / html component - need converter

asked 2024-03-28 21:45:51 +0800

holos gravatar image holos
41 6

I am using the searchbox component which allows only a label or a html component as part of its body template.

I would like to extend the "label" variant:

<searchbox model="@load(vm.users)">
  <template name="model">
    <label value="@init(each) @converter('user')"/>
  </template>
</searchbox>

into a html component variant:

<searchbox model="@load(vm.users)">
  <template name="model">
  <html><![CDATA[
   <i class="z-icon-user"></i> ${each}
   ]]>
  </html>
  </template>
</searchbox>

But I need to apply @converter('user') to ${each}.

How can I do this?

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2024-04-02 12:45:48 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

Another way:

<template name="model">
    <html content="@init(each)@converter('user')"/>
</template>

In the user converter, you convert each User object to HTML and prepended <i class="z-icon-user"></i>

link publish delete flag offensive edit

Comments

OK, that will work. Thanks.

holos ( 2024-04-02 15:39:12 +0800 )edit
0

answered 2024-04-01 10:59:38 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

the converter is a java objcet running at the server side, but you also need a client-side custom DOM element structure.

I recommend the solutions:

convert the model first

convert each object in vm.users into the expected first, then you don't need to apply the converter on each ${ech}

custom item render

Create a custom item render, call the converter to convert each object in the item render and produce a custom HTML snippet.

link publish delete flag offensive edit

Comments

Both solutions are obviously either not what I expected or at least way too complicated. Bottomline of my question is rather: can I use converters on initial attributes like ${name} and the answer looks like: no. If only HTML component could also allow MVVM attributes like @load(name) ... :-)

holos ( 2024-04-02 03:17:01 +0800 )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

RSS

Stats

Asked: 2024-03-28 21:45:51 +0800

Seen: 8 times

Last updated: Apr 02

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