MultiSelect: lazy load & custom renderer
Components / Samples
Description
This sample shows how to use the Kendo UI MultiSelect.
Note
MultiSelect inherits from ListMultipleChoice, but #setMaxRows(int) has not effect with this widget. The height option can be used instead.Warning
Do not re-attach the MultiSelect directly to the AjaxRequestTarget, attach its container instead (the form for instance)Since
wicket-kendo-ui-6.14.0Licensing
Kendo UI "Core" is Apache License 2.0 licensed, starting from version 2014.1.416.Prior to version 2014.1.416, Kendo UI "Web" was licensed under GPLv3.
A pro version - with a commercial license - is also available, it provides additional widgets (see http://docs.telerik.com/kendo-ui/intro/supporting/list-of-widgets)
To be able to use it, you need to change the
ResourceReference
with kendo.all.min.js
See also
[howto]-change-resource-referencesSources
- Java
- HTML
- CSS
package com.googlecode.wicket.jquery.ui.samples.kendoui.multiselect; import java.util.Collection; import java.util.List; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.markup.html.form.ChoiceRenderer; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.model.Model; import org.apache.wicket.util.lang.Generics; import com.googlecode.wicket.jquery.ui.samples.data.bean.Genre; import com.googlecode.wicket.jquery.ui.samples.data.dao.GenresDAO; import com.googlecode.wicket.kendo.ui.form.button.AjaxButton; import com.googlecode.wicket.kendo.ui.form.button.Button; import com.googlecode.wicket.kendo.ui.form.multiselect.MultiSelect; import com.googlecode.wicket.kendo.ui.panel.KendoFeedbackPanel; public class RendererMultiSelectPage extends AbstractMultiSelectPage { private static final long serialVersionUID = 1L; public RendererMultiSelectPage() { Form<Void> form = new Form<Void>("form"); this.add(form); // FeedbackPanel // final KendoFeedbackPanel feedback = new KendoFeedbackPanel("feedback"); form.add(feedback); // MultiSelect // List<Genre> selected = Generics.newArrayList(); selected.add(GenresDAO.get(2)); selected.add(GenresDAO.get(4)); final MultiSelect<Genre> multiselect = new MultiSelect<Genre>("select", Model.ofList(selected), GenresDAO.all(), new ChoiceRenderer<Genre>("name", "id")); form.add(multiselect.setOutputMarkupId(true)); // Buttons // form.add(new Button("submit") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { RendererMultiSelectPage.this.info(multiselect); } }); form.add(new AjaxButton("button") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target) { RendererMultiSelectPage.this.info(multiselect); target.add(feedback); } }); } private void info(MultiSelect<Genre> multiselect) { Collection<Genre> choice = multiselect.getModelObject(); this.info(choice != null ? choice.toString() : "no choice"); } }
<!DOCTYPE html> <html xmlns:wicket="http://wicket.apache.org"> <head> <wicket:head> <title>Wicket Kendo UI: multi-select (custom renderer)</title> </wicket:head> </head> <body> <wicket:extend> <div id="demo-panel"> <form wicket:id="form"> <select wicket:id="select" style="width: 460px;"></select> <br/> <button wicket:id="submit" type="submit">Submit</button> <button wicket:id="button">Ajax Button</button> <br/><br/> <div wicket:id="feedback" style="width: 460px;"></div> </form> </div> </wicket:extend> </body> </html>