This is a migrated thread and some comments may be shown as answers.

DataSource.requestEnd event... fully functional in 808 internal build?

8 Answers 494 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 11 Aug 2012, 05:36 AM
Hey guys,

I was looking at the latest internal build (808), and it looked like you guys implemented RequestEnd on the DataSource, which is going to solve a number of problems I'm having in my app. So I set up the following code:

    updateComplete = function(e) {
        alert(e.type);
    };
 
    $(document).ready(function () {
 
        var floorPlanDataSource = $("#propertyUnitEditGrid").data("kendoGrid").dataSource;
        floorPlanDataSource.bind("requestEnd", updateComplete);
));

The problem is, this event appears to only fire on the first read. My grid is using a remote datasource in batch mode, and the event does not fire when I add, update, or delete a row (with the built-in toolbar buttons), nor does it fire when I hit the built-in refresh button in the footer.

Digging through the code, it appears the event is wired into the sync, success, and error functions... but the only place the success function appears to be wired into is the Read function on the RemoteTransport class. If you look at the create, update, and destroy methods on RemoteTransport, you'll see they don't appear to leverage the success or error functions at all... at least, not the way you would expect.

It seems to me that an easier implementation of all of this would be to modify the Transports to start the CRUD methods by throwing the requestStart event, then passing in wrapped success and error functions that work similarly to the existing read method, where requestEnd is thrown before the passed in success or error handler is executed.

Then, the dataSource would handle these events from the Transport, and re-throw them back down to the implementer.

So 1) is the feature in its current state considered complete?
2) Did I hit a bug or am I doing something wrong?
3) Does my explanation of a "better" approach make sense?

Thanks!

Edit: I was doing something wrong. Mental note: Next time, test new Kendo feature on page with one Grid, not seven. I pasted in the wrong GridID, to the bind function, so I was testing the results in a different grid than the one that was wired up. My bad.

8 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 13 Aug 2012, 08:30 AM
Hi Robert,

 The requestEnd event should be raised after a remote sync operation is complete. If the dataSource's sync method is not called a request to the server is not made unless autoSync is set to true.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Robert
Top achievements
Rank 1
answered on 13 Aug 2012, 01:17 PM
I respectfully submit that implementation does not make any sense. The name of the event is requestEnd, not syncEnd. Based on the name, it should fire every time an HTTP request finishes, not every time the Sync method is called. The reason I say this is because hitting the Save button on the Grid fires an HTTP request to update the data. When that HTTP request finishes, the requestEnd event should fire, whether I have set some flag on the the DataSource or not.

If it behaves the way you intended, then the event names should be syncStart and syncEnd, and you need to create new events called requestStart and requestEnd that are fired immediately before and immediately after you call $.ajax for an action on the DataSource.

0
Atanas Korchev
Telerik team
answered on 13 Aug 2012, 02:26 PM
Hello,

 The Kendo DataSource will not make any HTTP request unless sync is called. To sum it up requestEnd is raised every time an HTTP request ends (response from server is received or error is thrown). However the DataSource does not make requests for creade/update/destroy operations until the sync method is called.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Robert
Top achievements
Rank 1
answered on 13 Aug 2012, 02:40 PM
-Post removed by OP.
0
Atanas Korchev
Telerik team
answered on 13 Aug 2012, 02:52 PM
Hello,

I tried it locally and it works as expected. Could you provide a sample application which fails at your side?

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Robert
Top achievements
Rank 1
answered on 13 Aug 2012, 03:05 PM
I will try to put together a jsFiddle that will recreate the issue.
0
Atanas Korchev
Telerik team
answered on 13 Aug 2012, 03:11 PM
Hello Robert,

 That would be awesome! You may have discovered a bug which definitely needs fixing. If you can't recreate it in a jsFiddle feel free to open a support ticket and attach a full project there.

Kind regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Robert
Top achievements
Rank 1
answered on 13 Aug 2012, 05:24 PM
In putting together my repro I discovered that I had only wired the event binding to one of the grids on a page with multiple grids, and through a copy-paste error was testing the event from the wrong grid. Will endeavor to test next time on a page that is less complicated before implementing on more complex pages. My bad. Thanks for your help.
Tags
Data Source
Asked by
Robert
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Robert
Top achievements
Rank 1
Share this question
or