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

Grid - create - read server response

6 Answers 507 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hessner
Top achievements
Rank 2
Hessner asked on 02 Feb 2012, 06:19 PM
Hi,

When adding rows to the grid and pressing "Create" a json package are sent to the server.

Thats fine,- but what about the server response,- how/where is it handled by the grid?

Serverside I validate for duplicates and want to tell the grid when the create did fail(or was a success) - how is this trivial task implemented?

1. Light up rows that are not valid
2. Alert the user

Been searching the forum/documentation - with no success.

6 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 07 Feb 2012, 11:16 AM
Hello Bo,

Currently you can handle error event of the DataSource and return details for the error from server side.
For more details please check the attached application and more precisly the on error handler and Update server action.

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Hessner
Top achievements
Rank 2
answered on 08 Feb 2012, 11:08 PM
Thank you for the application - it showed me things that was unclear to me.

Could you please inform me how to react in the following scenario:

1. I add 2 new rows into the grid, where one has a product name that already exists - I press "Save changes".
2. Serverside I tjek for duplicate product names - if found I do not insert anything, but return the row(s) to the client that contain duplicate product names.
3. Clientside the rows that caused the "abort" are highlighted.
4. The user correct the names(or remove rows) and press "Save changes" again
5. All is good.

I try this serverside:
throw new WebFaultException<List<RoleMapEntityDto>>(roleList, System.Net.HttpStatusCode.Forbidden);

but clientside this code does not make much sense to me:
error: function(e) {
               var grid = $("#grid").data("kendoGrid"),
                   item = JSON.parse(e.responseText),
                   tr = grid.table.find("tr[data-id=" + item.ProductID + "]");
                
               tr.fadeOut("slow", function() {
                   tr.fadeIn("fast");
               });
           }

e.reponseText contain the model that was sent down(filtered so only the duplicate name rows are returned).

clientside the "data-id"(on new rows) seem to be a temp guid that are not sent to the server - so how to find it again, I dont know.

Regards
Hessner
0
Nikolay Rusev
Telerik team
answered on 13 Feb 2012, 12:12 PM
Hello Hessner,

For all new rows guid is created so the rows can be uniquely identified. However this guid is only for internal use and is not send to server as it is not part of the entity data.

Unfortunately you cannot accept only partially the request. If there is an error all the items send from the grid to the remote location will be rejected and will remain as not accepted from the grid /similar to what happens with the update method/.

Greetings,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Erlend
Top achievements
Rank 2
answered on 24 Apr 2012, 02:11 PM
on the other side of this issue, 
is there a way to implement
success : function (e){ // do something }
on the dataSource, in the same manner as error?

How to tap into the server communication if you want to notify user of a successful operation and do some operation based on this.

Thanks,  
0
Alexander Valchev
Telerik team
answered on 27 Apr 2012, 09:55 AM
Hi Erlend,

Please check this forum topic, it discusses the same topic - dataSource success event.
I hope you will find the answer of your questions there.

Greetings,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Erlend
Top achievements
Rank 2
answered on 27 Apr 2012, 09:58 AM
Thanks,

Found this myself later, and would be good to update your documentation to point out that callback events on the transport definition also can implement the $.ajax callback methods.
Tags
Grid
Asked by
Hessner
Top achievements
Rank 2
Answers by
Nikolay Rusev
Telerik team
Hessner
Top achievements
Rank 2
Erlend
Top achievements
Rank 2
Alexander Valchev
Telerik team
Share this question
or