Coordinating with remote update routine that adjusts field values

3 posts, 1 answers
  1. Richard
    Richard avatar
    145 posts
    Member since:
    Feb 2012

    Posted 27 Sep 2017 Link to this post

    Suppose I have a data source with fields id and x that comes from a table foobar.

    The view model is id, x, xorig.  For read operations the xorig value is also set to the x value

    The peculiar rules for foobar is that when an x is to be updated it will try to honor the requested x, otherwise it will return a new x value

    The data source is configured for batch mode.

    The read gets a row id=1, x=10

    The user edits x to be 20 and hits a save changes button.  The update transport sends json via parameterMap [ {id:1, x:20, xorig:10} ]

    The update routine will send back [ {id:1, x:20, xorig:20} ] if the edit was honored, or perhaps [ {id:1,x:55,xorig:55} ] if the 20 could not be honored and the peculiar rules determined x should be 55 instead.

    How and where can I capture the update response and tweak the data source elements to match the update response. For example:

    for (var i=0; i<updateResponseData.length; i++) {
        var responseItem = updateResponseData[i];
        var datasorcItem = myDataSource.get(;
        datasorcItem.x = responseItem.x;
        datasorcItem.xorig =responseItem.xorig;
        datasorcItem.dirty = false;




  2. Answer
    Konstantin Dikov
    Konstantin Dikov avatar
    2183 posts

    Posted 29 Sep 2017 Link to this post

    Hello Richard,

    If I understand correctly the scenario, it should be possible to modify the data within the requestEnd event of the DataSource, by retrieving the returned data from the response. More information on this event is available in the following help topic:
    On a side note, after an update request, if you modify the passed value on server-side, once that value is returned to the DataSource it should be updated accordingly. The same could be observed when the "ID" is set for new records on server-side for example. 

    Konstantin Dikov
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Richard
    Richard avatar
    145 posts
    Member since:
    Feb 2012

    Posted 02 Oct 2017 in reply to Konstantin Dikov Link to this post

    Thanks Konstantin.

    Coding a requestEnd event handler is what I needed. Addtionally the .set() method was used to perform the value assignmnents for the updated items. For example:

    datasorcItem.set('x', responseItem.x);

Back to Top