Force-refreshing a KendoComboBox datasource (6.26.0)

506 views
Skip to first unread message

Richard Eckart de Castilho

unread,
Feb 21, 2017, 4:47:55 PM2/21/17
to wicket-jquery-ui
Hi,

I'm again facing some problems with the Kendo ComboBox. In 6.26.0, I now see the following code in the page:

jQuery(function() { window.featureEditorHead1558_datasource = new kendo.data.DataSource({ "dataType": "json", "transport": { "read": "./annotation.html?13-9.IBehaviorListener.1-sidebarCell-annotationDetailEditorPanel-annotationFeatureForm-featureEditorsContainer-featureValues-99-editor-value" }, "error": function (xhr, error) { var dw = Wicket.Ajax.DebugWindow; if (typeof dw !== 'undefined') { dw.logError(kendo.stringify(xhr)); } }, "sync": function() { this.read(); } }); });

So the dropdown contents are loaded once via a separate XHR.

After rendering the ComboBox the first time and after the datasource has loaded its content, I make changes at the backend which change the data for the datasource box. However, re-rendering the ComboBox (i.e. adding it to an AjaxTarget) does not trigger a reload of the datasource.

Is there some way I can force the reloading of the datasource e.g. during ComboBox.onInitialize()?

Cheers,

-- Richard

Sebastien

unread,
Feb 21, 2017, 5:57:31 PM2/21/17
to wicket-j...@googlegroups.com
Hi Richard,

You are right, it seems to be missing!
I cannot commit in the 6.x branch today, but I will do it asap (I need to also do in the other datasource-based components)

Meanwhile you can add it in your own combobox:

    /**
     * Gets the Kendo UI widget
     *
     * @return the jQuery object
     */
    public String widget()
    {
        return KendoUIBehavior.widget(this, ComboBoxBehavior.METHOD);
    }

    /**
     * Refreshes the widget by reading from the datasource
     *
     * @param target the {@link AjaxRequestTarget}
     */
    public void refresh(AjaxRequestTarget target)
    {
        target.appendJavaScript(String.format("var $w = %s; if ($w) { $w.dataSource.read(); }", this.widget()));
    }

Please tell me if it is working as expected.
You can also open an issue so you will be informed when the #refresh method will be available :)

Thanks & best regards,
Sebastien.

Richard Eckart de Castilho

unread,
Feb 22, 2017, 4:07:05 AM2/22/17
to wicket-j...@googlegroups.com
Hi Sebastien,

I can trigger the reload with this, but it turns out that unfortunately it does not solve my problem.
Actually in my special case I then get an exception that the required component is no longer added to the page.

The reason is that I keep the combobox in a repeater and every time I refresh the repeater,
a new combobox gets created. While I force the markupIds of the combobox to remain the same
(e.g. to allow Wicket to set the focus back to this component after an Ajax refresh), the
Ajax URL of the underlying datasource keeps changing.

I have now tried caching the combobox the first time and re-adding the same one whenever the
repeater is refreshed, but still running into issues that I don't fully understand yet.

Cheers,

-- Richard
Reply all
Reply to author
Forward
0 new messages