sebfz1 / wicket-jquery-ui

jQuery UI & Kendo UI integration in Wicket
http://www.7thweb.net/wicket-jquery-ui/
Other
92 stars 58 forks source link

Please feature getChoices() filtered via keyboard input for KendoUI MultiSelect #336

Closed Patrick1701 closed 3 years ago

Patrick1701 commented 3 years ago

Hi Sebastien, we have a quite custom version of a multiselect, I would like to get rid off.

A key feature is missing at the current impls of your KendoUI MultiSelects. Filtering the choices by input, like for autocomplete text fields, to be able to fetch them from a database, containing a huge amount of possible choice-values.

As far as I can see, the Lazy Multiselect seems to be best candidate for, because it already provides a datasource with a transport read callback to the server. Could you provide a version with a filter feature like the kendoUI autocomplete.

thanx a lot Patrick

sebfz1 commented 3 years ago

Hi Patrick,

I set serverFiltering=true by detault. The #getChoice method has its signature changed as well. Your usage might be something like this:

final MultiSelect<String> multiselect = new MultiSelect<String>("select", Model.ofList(selected)) {

    private static final long serialVersionUID = 1L;

    @Override
    public void onConfigure(JQueryBehavior behavior)
    {
        super.onConfigure(behavior);

        behavior.setOption("minLength", 2);
        behavior.setOption("enforceMinLength", true);
        // If set to true the widget will not show all items when the text of the search input cleared.
        // By default the widget shows all items when the text of the search input is cleared. Works in conjunction with minLength.
    }

    @Override
    protected List<String> getChoices(String input)
    {
        // Even with enforceMinLength=true, the widget may send an empty request (on remove-focus for instance)
        if (!Strings.isEmpty(input))
        {
            return ListUtils.startsWith(input, GENRES); // lookup in your DAO, etc...
        }

        return Collections.emptyList();
    }
}

If you have other MultiSelect you don't want to have the serverFiltering=true, you can do like this:

final AjaxMultiSelect<String> multiselect = new AjaxMultiSelect<String>("select", Model.ofList(selected)) {

    private static final long serialVersionUID = 1L;

    @Override
    protected void onConfigure(KendoDataSource dataSource)
    {
        super.onConfigure(dataSource);

        dataSource.set("serverFiltering", false); // default is true
    }

    @Override
    protected List<String> getChoices(String input)
    {
        // note: 'input' is always empty when serverFiltering=false
        return myChoices;
    }
}

I deployed 8.12.1-SNAPSHOT and 9.3.3-SNAPSHOT. Please give it a try and I will release next week-end.

Patrick1701 commented 2 years ago

@sebfz1 Sorry, for replying late. I will have a test. Unfortunately, currently I'm not able to connect sonatype to get the snapshot, caused by company network restrictions. I try to find a solution, and will give feedback.

Patrick

sebfz1 commented 2 years ago

Maybe you can checkout the repo and build locally (just for testing purpose)?

Patrick1701 commented 2 years ago

@sebfz1 I tried, but where do I find the branch for 8.12.1-SNAPSHOT?

sebfz1 commented 2 years ago

I committed on wicket8.x branch

Patrick1701 commented 2 years ago

@sebfz1 Ah, the open 8.x branch is at 8.12.1-SNAPSHOT... ok, I see. Sorry.

Patrick1701 commented 2 years ago

@sebfz1 It seems the case-sensitiv filtering is not working. I always get a lower-case input String.

Patrick1701 commented 2 years ago

@sebfz1 I think it works quite good, except the lower-case issue which is not a huge problem to us. If you like you can create a release.

8.12.x is fine, 8.10.x would be great.

regards Patrick