Announcement Announcement Module
Collapse
No announcement yet.
Filtered Select option List Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Filtered Select option List

    Is there a way to filter the values on a table sourced select list (combo box or multi-select)?

    For example, using the Pet Clinic sample. If you added a boolean column called 'active' for the specialtys. How would you change the Vet create form multi-select to only show the items where active = true?

    Sorry if this is a dumb question. I'm still learning.

  • #2
    Well... I'm not too sure this is the best way to accomplish what I need, but here is what I have working:

    <div id="roo_vet_specialties">
    <c:if test="${not empty specialtys}">
    <label for="_specialties">Specialties:</label>
    <form:select cssStyle="width:250px" id="_specialties" path="specialties">
    <c:forEach items="${specialtys}" var="specialty">
    <c:choose>
    <c:when test="${specialty.active == true}" >
    <form:option value="${specialty.id}" label="${specialty.name}"/>
    </c:when>
    <c:otherwise>
    </c:otherwise>
    </c:choose>
    </c:forEach>
    </form:select>
    <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : '_specialties', widgetType: 'dijit.form.MultiSelect', widgetAttrs: {}})); </script>
    </c:if>
    </div>

    Comment


    • #3
      This is not supported by Roo out of the box but it should be really easy to do this with a little manual work.

      First, I would suggest you create a finder which does similar things (use the 'finder' command). Once you have a finder method in your entity, you can push it in an refine it as needed (you can create a join between both tables).

      Second, you push in the relevant form method in your controller and customize the part where findAll is called. This could be replaced by using your new finder method in Vet:

      Code:
      modelMap.addAttribute("vets", Vet.findActiveVets());
      HTH,
      Stefan

      Comment

      Working...
      X