Grid - create - read server response

7 posts, 0 answers
  1. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 02 Feb 2012 Link to this post

    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.
  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 07 Feb 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 08 Feb 2012 Link to this post

    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
  5. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 13 Feb 2012 Link to this post

    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!
  6. Erlend
    Erlend avatar
    11 posts
    Member since:
    Apr 2011

    Posted 24 Apr 2012 Link to this post

    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,  
  7. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 27 Apr 2012 Link to this post

    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!
  8. Erlend
    Erlend avatar
    11 posts
    Member since:
    Apr 2011

    Posted 27 Apr 2012 Link to this post

    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.
Back to Top
Kendo UI is VS 2017 Ready