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

Row click handler for DataTable #320

Closed mdbergmann closed 3 years ago

mdbergmann commented 3 years ago

Hi.

Please see the Wicket mailing list. http://apache-wicket.1842946.n4.nabble.com/Kendo-DataTable-row-click-handler-td4684468.html

We're using Wicket 8.9.0. Looking at the DataTable class, how would the click event being transported to the Java part? I think that's missing or? Can you check?

sebfz1 commented 3 years ago

Hi,

I wired the change js-event to DataTable#onChange event which respond when the user selects a row. The event is automatically enabled if you provide the selectable option:

options.set("selectable", true);
options.set("selectable", Options.asString("row")); 
options.set("selectable", Options.asString("multiple, row")); 

caution does not work for cell

The onChange usage is like this for instance:

final DataTable<Product> table = new DataTable<Product>("datatable", newColumnList(), newDataProvider(), 25, options) {

    @Override
    public void onChange(AjaxRequestTarget target, JSONArray items)
    {
        final List<Integer> ids = JsonUtils.toJSONList(items).stream().map(o -> o.getInt("id")).collect(Collectors.toList());
        final String message = String.format("Selected: %s", ids);

        feedback.info(message);
        feedback.refresh(target);
    }
};
mdbergmann commented 3 years ago

Many thanks.