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

KendoUI Datasource / changes in implementation #240

Open Patrick1701 opened 8 years ago

Patrick1701 commented 8 years ago

Hi,

while debugging the problem of https://github.com/sebfz1/wicket-jquery-ui/issues/239 I played a bit with the datasources and attempted to remove this method, which creates a manual ajax call in the SchedulerBehavior.

(shorten snippet)

    /**
     * Gets the 'read' callback function<br/>
     * As create, update and destroy need to be supplied, we should declare read as a function. Weird...
     *
     * @return the 'read' callback function
     */
    private String getReadCallbackFunction()

return "function(options) {" // lf
                + " jQuery.ajax({" // lf
                + "     url: '" + this.getDataSourceUrl() + "'," // lf

    }

I thought it could be the problem for 239, but it is not... but I got a very interesting datasource implementation, I like to share with you.

After some research I made a prototypical implementation following the instructions on this apis/articles/code examples.

Using data fields in Datasources: http://docs.telerik.com/kendo-ui/framework/datasource/basic-usage#creating-a-datasource-for-remote-data

Recommendation of using the data field: http://docs.telerik.com/kendo-ui/web/scheduler/overview#example---binding-to-remote-service (you are already using the data parameter, but a bit different)

example of getting data: https://github.com/telerik/ui-for-aspnet-mvc-examples/blob/master/scheduler/scheduler-server-filtering/KendoUI_Scheduler_Server_Filtering/Views/Home/Index.cshtml

The implementation looks cleaner without the wicket javascripts in between, but I'm not sure if it would fully achieve all features, you are already implemented in KendoDataSource and its existing subclasses. It looks to me you implemented a reusable KendoDataSource implementation, which is statefull per page and can be used by kendo components, e.g. Scheduler where you just provide a pointer to the js SchedulerDataSource.

In this version, I'm only using urls (no delegation into wickets javascript calls and ajax requests). It’s a bit more kendo-like, I think.

But it would need reviewed and finished by you. After recognizing these changes wouldn't help finding 239 (still have double requests), I cannot go further due to project time pressure, but I don't want to get this code lost.

I provided the code into a branch called 'wicket-jquery-ui-6.23.0-DataSource-Prototype'.

If you like have a look, maybe you can use it, adapt and fulfill.

Open issues:

Best regards Patrick

sebfz1 commented 8 years ago

Hi Patrick,

As the code snippet you pasted mentions, I cannot use an url for Read operation whenever the other CUD operations needs a callback function (and they need)... However, I will double check if Kendo UI corrected this (wrong) behavior...

The problem of dual refresh may come from the sync datasource option (see KendoDataSource ctor). Just a guess however...

Thanks & best regards, Sebastien.